Package: hatched
hatchedLibrary andvpypeplug-in to convert images to plotter-friendly, hatched patterns.Built withOpenCV,scikit-image,Shapely,matplotlibandsvgwrite. You can reach the authorDrawingbots'sDiscord server.Getting StartedUsing withvpypeUsinghatchedas avpypeplug-in is the easiest way to get started. Seevpype'sinstallation instructionsfor information on how to installvpype.Ifvpypewas installed using pipx, use the following command:$pipxinjectvpypehatchedIfvpypewas installed using pip in a virtual environment, activate the virtual environment and use the following command:$pipinstallhatchedYou can confirm that the installation was successful with the following command, which also happens to tell you all
you need to know to usehatched:$vpypehatched--help
Usage:vpypehatched[OPTIONS]FILENAMEGeneratehatchedpatternfromanimage.Thehatchesgeneratedareinthecoordinateoftheinputimage.Forexample,a100x100pximagewithgeneratehatcheswhoseboundingboxcoordinatesare(0,0,100,100).The`--scale`option,byresamplingtheinputimage,indirectlyaffectsthegeneratedboundingbox.The`--pitch`parametersetsthedensesthatchingfrequency,

Options:--levelsINTEGER...Pixelvalueofthe3thresholdsbetweenblack,dark,lightandwhitezones(0-255).-s,--scaleFLOATScalefactortoapplytotheimagesize.-i,--interpolation[linear|nearest]Interpolationusedforscaling.-b,--blurINTEGERBlurradiustoapplytotheimagebeforeapplyingthresholds.-p,--pitchLENGTHHatchingpitchforthedensestzones.Thisoptionunderstandssupportedunits.-x,--invertInverttheimage(andlevels)beforeapplyingthresholds.-c,--circularUsecircularinsteadofdiagonalhatches.-o,--centerOriginofcirclesrelativetotheimagesize.Forexample,(0.5,0.5)correspondstothecenteroftheimage.-a,--angleAnglefordiagonalhatches(indegrees)-d,--show-plotDisplaythecontoursandresultingpatternusingmatplotlib.-l,--layerLAYERTargetlayeror'new'.--helpShowthismessageandexit.To create a SVG, combine thehatchedcommand with thewritecommand (checkvpype's documentation for more
information). Here is an example:$vpypehatched--levels64128192-s0.5-p4input.jpglayouta4writeoutput.svgUsinghatchedas a libraryTo play withhatched, you need to checkout the source and install the dependencies in a virtual environment, for
example with the following steps:$gitclonehttps://github.com/plottertools/hatched.git
$cdhatched
$python3-mvenvvenv
$sourcevenv/bin/activate
$pipinstall-rrequirements.txtRunning the exampleExample can then be run by executing the corresponding file:$cdexamples
$pythonskull.pyThe processing result is displayed in a matplotlib window:Askull.svgfile is also created with the output graphics.UsageCall the functionhatched.hatch()to process your image. It takes the following parameters:file_path: input image (most common format are accepted)image_scale: scale factor to apply to the image before processinginterpolation: interpolation to apply for scaling (typically eithercv2.INTER_LINEARorcv2.INTER_NEAREST)blur_radius: blurring radius to apply on the input image (0 to disable)hatch_pitch: hatching pitch in pixel (corresponds to the densest possible hatching)levels: tuple of the n thresholds for different shades (0-255). The plugin only accepts 3 thresholds, but using as a library it accepts any number.h_mirror: apply horizontal mirror on the image if Trueinvert: invert pixel value of the input image before processing (in this case, the level thresholds are inverted as well)circular: use circular hatching instead of diagonalcenter: relative position of cirles' center when using circular hatchinghatch_angle: hatching angle for diagonal hatches (in degrees)show_plot: (default True) display contours and final results with matplotlibsave_svg: (default True) controls whether or not an output SVG file is createdLicenseThis project is licensed under the MIT License - see theLICENSEfile for details.The example imageskull.jpgis licenced under aCreative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.