Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
type=Length(),
help="Hatching pitch for the densest zones. This option understands supported units.",
)
@click.option(
"-x",
"--invert",
is_flag=True,
help="Invert the image (and levels) before applying thresholds.",
)
@click.option(
"-c", "--circular", is_flag=True, help="Use circular instead of diagonal hatches."
)
@click.option(
"-d",
"--show-plot",
is_flag=True,
help="Display the contours and resulting pattern using matplotlib.",
):
"""
Generate hatched pattern from an image.
The hatches generated are in the coordinate of the input image. For example, a 100x100px
image with generate hatches whose bounding box coordinates are (0, 0, 100, 100). The
`--scale` option, by resampling the input image, indirectly affects the generated bounding
box. The `--pitch` parameter sets the densest hatching frequency,
"""
logging.info(f"generating hatches from {filename}")
interp = cv2.INTER_LINEAR
if interpolation == "nearest":
interp = cv2.INTER_NEAREST
return LineCollection(
hatched.hatch(
file_path=filename,
levels=levels,
image_scale=scale,
interpolation=interp,
blur_radius=blur,
hatch_pitch=pitch,
invert=invert,
circular=circular,
show_plot=show_plot,
h_mirror=False, # this is best handled by vpype
save_svg=False, # this is best handled by vpype
)
@generator
def hatched_gen(
filename: str,
levels,
scale: float,
interpolation: str,
blur: int,
pitch: int,
invert: bool,
circular: bool,
show_plot: bool,
):
"""
Generate hatched pattern from an image.
The hatches generated are in the coordinate of the input image. For example, a 100x100px
image with generate hatches whose bounding box coordinates are (0, 0, 100, 100). The