def quantization_option(function): function = click.option( "-q", "--quantization", type=vpype_cli.LengthType(), default="0.1mm", help="Quantization used when loading tiles (default: 0.1mm)", )(function) return function
lc.merge(tolerance=pen_width * 5, flip=True) print(p.geom_type) boundary = p.boundary if boundary.geom_type == "MultiLineString": lc.extend(boundary) else: lc.append(boundary) return lc @click.command() @click.option( "-pw", "--pen-width", type=vpype_cli.LengthType(), default="0.3mm", help="Pen width (default: 0.3mm)", ) @click.option( "-t", "--tolerance", type=vpype_cli.LengthType(), default="0.01mm", help="Max distance between start and end point to consider a path closed " "(default: 0.01mm)", ) @click.option("-k", "--keep-open", is_flag=True, help="Keep open paths") @vpype_cli.layer_processor def fill(lines: vp.LineCollection, pen_width: float, tolerance: float, keep_open: bool) -> vp.LineCollection:
import click import vpype as vp import vpype_cli from shapely.geometry import Polygon @click.command() @click.argument("X", type=vpype_cli.LengthType()) @click.argument("Y", type=vpype_cli.LengthType()) @click.argument("R", type=vpype_cli.LengthType()) @click.option( "-q", "--quantization", type=vpype_cli.LengthType(), default="0.1mm", help="Quantization used for the circular area", ) @vpype_cli.layer_processor def circlecrop(lines: vp.LineCollection, x: float, y: float, r: float, quantization: float): """Crop to a circular area.""" circle = Polygon(vp.as_vector(vp.circle(x, y, r, quantization))) mls = lines.as_mls() return vp.LineCollection(mls.intersection(circle))
-1 + 1j, -1 - 1j, 1 - 1j, 1 + 2j, -2 + 2j, -2 - 2j, 2 - 2j, 2 + 2j, ] PIXEL_OFFSET = 5 @click.command() @click.argument("image", type=vpype_cli.PathType(exists=True, dir_okay=False)) @click.option("-pw", "--pen-width", type=vpype_cli.LengthType(), default="0.6mm") @click.option( "-m", "--mode", type=click.Choice(choices=["big", "line"], case_sensitive=False), default="big", help="operation mode", ) @vpype_cli.global_processor def pixelart(document: vp.Document, image, mode, pen_width: float): """Plot pixel art. Two modes are available: - "big" creates a square spiral for each pixel - "line" create single horizontal lines for contiguous pixels of the same color """