Exemplo n.º 1
0
    return lines


def _normalize_page_size(page_size: Tuple[float, float],
                         landscape: bool) -> Tuple[float, float]:
    """Normalize page size to respect the orientation."""
    if (landscape and page_size[0] < page_size[1]) or (
            not landscape and page_size[0] > page_size[1]):
        return page_size[::-1]
    else:
        return page_size


@cli.command(group="Operations")
@click.argument("size", type=vp.PageSizeType(), required=True)
@click.option("-l",
              "--landscape",
              is_flag=True,
              default=False,
              help="Landscape orientation.")
@vp.global_processor
def pagesize(document: vp.Document, size, landscape) -> vp.Document:
    """Change the current page size.

    The page size is set (or modified) by the `read` command and used by the `write` command by
    default. This command can be used to set it to an arbitrary value. See the `write` command
    help section for more information on valid size value (`vpype write --help`).

    Note: this command only changes the current page size and has no effect on the geometries.
    Use the `translate` and `scale` commands to change the position and/or the scale of the
Exemplo n.º 2
0
from typing import Tuple

import click
import vpype as vp
import numpy as np
#import ConfigParser #for plotter hard clips


@click.command()
@click.argument("output", type=click.File("w"))
@click.option(
    "-p",
    "--page-format",
    type=vp.PageSizeType(),
    default="tight",
    help="Set the page format.",
)
@click.option(
    "-l",
    "--landscape",
    is_flag=True,
    help="Use landscape orientation instead of portrait.",
)
@click.option(
    "-c",
    "--center",
    is_flag=True,
    help="Center the geometries within the SVG bounds.",
)
@vp.global_processor
def hpgl(