{"id":13595704,"url":"https://github.com/plottertools/hatched","last_synced_at":"2025-04-09T13:33:14.329Z","repository":{"id":40994071,"uuid":"219463850","full_name":"plottertools/hatched","owner":"plottertools","description":"Convert images to plotter-friendly hatched patterns","archived":false,"fork":false,"pushed_at":"2025-03-07T09:41:23.000Z","size":621,"stargazers_count":111,"open_issues_count":3,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T04:17:54.099Z","etag":null,"topics":["generative-art","hacktoberfest","pen-plotter","plotter-art"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plottertools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["abey79"],"ko_fi":"abey79"}},"created_at":"2019-11-04T09:29:38.000Z","updated_at":"2025-04-06T15:04:20.000Z","dependencies_parsed_at":"2022-09-20T20:00:37.792Z","dependency_job_id":null,"html_url":"https://github.com/plottertools/hatched","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plottertools%2Fhatched","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plottertools%2Fhatched/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plottertools%2Fhatched/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plottertools%2Fhatched/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plottertools","download_url":"https://codeload.github.com/plottertools/hatched/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248049632,"owners_count":21039252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generative-art","hacktoberfest","pen-plotter","plotter-art"],"created_at":"2024-08-01T16:01:55.963Z","updated_at":"2025-04-09T13:33:13.772Z","avatar_url":"https://github.com/plottertools.png","language":"Python","readme":"# _hatched_\n\n\u003cimg src=\"https://i.imgur.com/QLlBpNU.png\" width=300 /\u003e \u003cimg src=\"https://i.imgur.com/fRIrPV2.jpg\" width=300 /\u003e\n\nLibrary and [vpype](https://github.com/abey79/vpype) plug-in to convert images to plotter-friendly, hatched patterns.\n\nBuilt with [OpenCV](https://github.com/skvark/opencv-python), [scikit-image](https://scikit-image.org),\n[Shapely](https://github.com/Toblerity/Shapely), [matplotlib](https://matplotlib.org) and\n[svgwrite](https://github.com/mozman/svgwrite). You can reach the author\n[Drawingbots](https://drawingbots.net)'s [Discord server](https://discordapp.com/invite/XHP3dBg).\n\n\n## Getting Started\n\n### Using with `vpype`\n\nUsing `hatched` as a [vpype](https://github.com/abey79/vpype) plug-in is the easiest way to get started. See _vpype_'s [installation instructions](https://vpype.readthedocs.io/en/latest/install.html) for information on how to install _vpype_.\n\nIf *vpype* was installed using pipx, use the following command:\n\n```bash\n$ pipx inject vpype hatched\n```\n\nIf *vpype* was installed using pip in a virtual environment, activate the virtual environment and use the following command:\n\n```bash\n$ pip install hatched\n```\n\nYou can confirm that the installation was successful with the following command, which also happens to tell you all\nyou need to know to use `hatched`:\n\n```bash\n$ vpype hatched --help\nUsage: vpype hatched [OPTIONS] FILENAME\n\n  Generate hatched pattern from an image.\n\n  The hatches generated are in the coordinate of the input image. For\n  example, a 100x100px image with generate hatches whose bounding box\n  coordinates are (0, 0, 100, 100). The `--scale` option, by resampling the\n  input image, indirectly affects the generated bounding box. The `--pitch`\n  parameter sets the densest hatching frequency,\n\nOptions:\n  --levels INTEGER...             Pixel value of the 3 thresholds between\n                                  black, dark, light and white zones (0-255).\n  -s, --scale FLOAT               Scale factor to apply to the image size.\n  -i, --interpolation [linear|nearest]\n                                  Interpolation used for scaling.\n  -b, --blur INTEGER              Blur radius to apply to the image before\n                                  applying thresholds.\n  -p, --pitch LENGTH              Hatching pitch for the densest zones. This\n                                  option understands supported units.\n  -x, --invert                    Invert the image (and levels) before\n                                  applying thresholds.\n  -c, --circular                  Use circular instead of diagonal hatches.\n  -o, --center                    Origin of circles relative to the image size.\n                                  For example, (0.5, 0.5) corresponds to the \n                                  center of the image.\n  -a, --angle                     Angle for diagonal hatches (in degrees)\n  -d, --show-plot                 Display the contours and resulting pattern\n                                  using matplotlib.\n  -l, --layer LAYER               Target layer or 'new'.\n  --help                          Show this message and exit.\n```\n\nTo create a SVG, combine the `hatched` command with the `write` command (check `vpype`'s documentation for more\ninformation). Here is an example:\n\n```bash\n$ vpype hatched --levels 64 128 192 -s 0.5 -p 4 input.jpg layout a4 write output.svg\n```\n\n\n### Using `hatched` as a library\n\nTo play with _hatched_, you need to checkout the source and install the dependencies in a virtual environment, for\nexample with the following steps:\n\n```bash\n$ git clone https://github.com/plottertools/hatched.git\n$ cd hatched\n$ python3 -m venv venv\n$ source venv/bin/activate\n$ pip install -r dev-requirements.txt\n```\n\n### Running the example\n\nExample can then be run by executing the corresponding file:\n\n```bash\n$ cd examples\n$ python skull.py\n```\n\nThe processing result is displayed in a matplotlib window:\n\n\u003cimg width=\"752\" alt=\"image\" src=\"https://user-images.githubusercontent.com/49431240/68111504-8a279700-feef-11e9-9205-c60f06cfb828.png\"\u003e\n\nA `skull.svg` file is also created with the output graphics.\n\n## Usage\n\nCall the function `hatched.hatch()` to process your image. It takes the following parameters:\n\n- `file_path`: input image (most common format are accepted)\n- `image_scale`: scale factor to apply to the image before processing\n- `interpolation`: interpolation to apply for scaling (typically either `cv2.INTER_LINEAR` or `cv2.INTER_NEAREST`)\n- `blur_radius`: blurring radius to apply on the input image (0 to disable)\n- `hatch_pitch`: hatching pitch in pixel (corresponds to the densest possible hatching)\n- `offset`: hatching starting position in pixels. Defaults to 0.\n- `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.\n- `h_mirror`: apply horizontal mirror on the image if True\n- `invert`: invert pixel value of the input image before processing (in this case, the level thresholds are inverted as well)\n- `circular`: use circular hatching instead of diagonal\n- `center`: relative position of cirles' center when using circular hatching\n- `hatch_angle`: hatching angle for diagonal hatches (in degrees)\n- `show_plot`: (default True) display contours and final results with matplotlib\n- `save_svg`: (default True) controls whether or not an output SVG file is created \n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\nThe example image `skull.jpg` is licenced under a \u003ca rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\"\u003eCreative Commons Attribution-NonCommercial-ShareAlike 4.0 International License\u003c/a\u003e.\n\n\u003ca rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/4.0/\"\u003e\u003cimg alt=\"Creative Commons License\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png\" /\u003e\u003c/a\u003e\n","funding_links":["https://github.com/sponsors/abey79","https://ko-fi.com/abey79"],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplottertools%2Fhatched","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplottertools%2Fhatched","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplottertools%2Fhatched/lists"}