{"id":15032389,"url":"https://github.com/marklagodych/svg_path_simplifier","last_synced_at":"2025-04-09T21:23:18.597Z","repository":{"id":65347187,"uuid":"587896712","full_name":"MarkLagodych/svg_path_simplifier","owner":"MarkLagodych","description":"Converts any SVG to move,line,cubic_bezier commands for robotic plotters","archived":false,"fork":false,"pushed_at":"2023-01-18T18:37:08.000Z","size":270,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T23:16:10.739Z","etag":null,"topics":["plotter","rust-lang","svg","vector-graphics"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/MarkLagodych.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-11T20:59:19.000Z","updated_at":"2024-12-19T08:54:51.000Z","dependencies_parsed_at":"2023-02-10T16:45:30.754Z","dependency_job_id":null,"html_url":"https://github.com/MarkLagodych/svg_path_simplifier","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkLagodych%2Fsvg_path_simplifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkLagodych%2Fsvg_path_simplifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkLagodych%2Fsvg_path_simplifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarkLagodych%2Fsvg_path_simplifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarkLagodych","download_url":"https://codeload.github.com/MarkLagodych/svg_path_simplifier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248113091,"owners_count":21049781,"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":["plotter","rust-lang","svg","vector-graphics"],"created_at":"2024-09-24T20:18:15.551Z","updated_at":"2025-04-09T21:23:18.575Z","avatar_url":"https://github.com/MarkLagodych.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SVG Path Simplifier\n\nThe `svgps` program converts `.svg` images into MoveTo/LineTo/CubicBezierTo commands\ncontained in a [`.svgcom`](#svgcom-format) file.\n\nThe initial goal was to prettify and simplify SVG for plotters.\n\nIt utilizes [usvg](https://github.com/RazrFalcon/resvg/tree/master/usvg) for SVG parsing and simplification\nand [kurbo](https://github.com/linebender/kurbo) for geometric calculations.\n\n## Demos\n\n| `XXXXXXXXXXXXXXXXX` | `XXXXXXXXXXXXXXXXX` | `XXXXXXXXXXXXXXXXX` |\n| --- | --- | --- |\n| Original SVG | Converted | Converted+autocut |\n| ![ferris](https://github.com/MarkLagodych/svg_path_simplifier/blob/main/demo/ferris.svg) | ![ferris-gen](https://github.com/MarkLagodych/svg_path_simplifier/blob/main/demo/ferris-converted.svg) | ![ferris-cut](https://github.com/MarkLagodych/svg_path_simplifier/blob/main/demo/ferris-converted-autocut.svg) |\n| ![tiger](https://github.com/MarkLagodych/svg_path_simplifier/blob/main/demo/tiger.svg) | ![tiger-gen](https://github.com/MarkLagodych/svg_path_simplifier/blob/main/demo/tiger-converted.svg) | ![tiger-cut](https://github.com/MarkLagodych/svg_path_simplifier/blob/main/demo/tiger-converted-autocut.svg) |\n\nSee [demo/gen.sh](./demo/gen.sh).\n\n## Features\n\n* Generating `.svgcom` from `.svg`\n* Rendering `.svgcom` to `.svg` for previewing\n* Selecting only stroked paths for the conversion\n* Autocutting path segments that are not visible because of being covered by other figures\n  (think of this as of a depth test)\n\n## Installation\n\nThis requires [Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html), the Rust package manager.\n\n```sh\ncargo install svg_path_simplifier\n```\n\n## Usage\n\n```sh\nsvgps help generate # Try this first to see all the options\nsvgps generate INPUT.svg OUTPUT.svgcom [OPTIONS...]\nsvgps render INPUT.svgcom OUTPUT.svg [OPTIONS...]\n```\n\n## Autocutting behavior\n\nThe `-a` (`--autocut`) flag makes the program cut the covered segments of the paths contained in the input SVG image.\n\nOnly closed filled paths can cover other paths.\n\n## SvgCom format\n\nSvgCom is a text format for vector graphics outline representation that borrows a lot from the\n[`\u003cpath:d\u003e`](https://www.w3.org/TR/SVG/paths.html#TheDProperty) format of SVG. \n\nThe file extension is `.svgcom`.\n\nThe file content is of the form:\n\n```\n\u003cviewbox_width: uint32\u003e\n\u003cSPACE\u003e\n\u003cviewbox_height: uint32\u003e\n\u003cSPACE\u003e\n\u003cnumber_of_commands: uint32\u003e\n\u003cSPACE\u003e\n\u003cnumber_of_coordinates: uint32\u003e\n\u003cEOL\u003e\n\n\u003ccommand: \"M\" | \"L\" | \"C\"\u003e... (not delimited)\n\u003cEOL\u003e\n\n\u003ccoordinate: float64\u003e... (delimited by \u003cSPACE\u003e)\n\n[\u003cEOL\u003e \u003cgarbage: text\u003e]\n```\n\nwhere `\u003cEOL\u003e` is `\u003cLF\u003e`, not `\u003cCR\u003e\u003cLF\u003e`, and `\u003cSPACE\u003e` is a *single* ASCII space.\n\nAdditional (\"garbage\") lines in the end of the file are optional and are never read by the converter.\n\nThe coordinate list specifies 2D point coordinates, thus the number of coordinates must be even.\n\n### Example 0\n\n`example.svgcom`\n```\n720 480 2 4\nML\n0 0 100 100\n```\n\nThis file defines an image of size `720`x`480`\nwith `2` commands (`M`ove and `L`ine)\nand `4` coordinates (`0.0`, `0.0`, `100.0`, `100.0`), which form two points.\n\n### Example 1\n\n`input.svg`\n```xml\n\u003c?xml version=\"1.0\" standalone=\"no\"?\u003e\n\u003csvg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 250 200\"\u003e\n    \u003c!-- Z is converted to L --\u003e\n    \u003cpath stroke=\"#000000\" fill=\"none\" d=\"M 0 0 L 100 0 L 100 70 L 0 70 Z\"/\u003e\n\u003c/svg\u003e\n```\n`output.svgcom`\n```\n250 200 5 10\nMLLLL\n0 0 100 0 100 70 0 70 0 0\n```\n\n### Example 2\n\n`input.svg`\n```xml\n\u003c?xml version=\"1.0\" standalone=\"no\"?\u003e\n\u003csvg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 800 600\"\u003e\n    \u003c!-- Hidden elements are removed --\u003e\n    \u003cpath stroke=\"#000000\" visibility=\"hidden\" fill=\"none\" d=\"M 0 0 L 100 0 L 100 70 L 0 70 Z\"/\u003e\n\n    \u003c!-- Groups are flattened --\u003e\n    \u003cg\u003e\n        \u003c!-- Transforms are resolved --\u003e\n        \u003cg transform=\"translate(0 0)\"\u003e\n            \u003c!-- All shapes are converted to paths --\u003e\n            \u003cellipse cx=\"100\" cy=\"100\" rx=\"50\" ry=\"60\"/\u003e\n        \u003c/g\u003e\n    \u003c/g\u003e\n\u003c/svg\u003e\n```\n\n`output.svgcom`\n```\n800 600 5 26\nMCCCC\n150 100 150 133.1370849898476 127.61423749153967 160 100 160 72.38576250846033 160 50.00000000000001 133.1370849898476 50 100.00000000000001 49.99999999999999 66.86291501015242 72.38576250846032 39.99999999999999 99.99999999999999 39.999999999999986 127.61423749153965 39.99999999999997 150 66.86291501015239 150 100\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarklagodych%2Fsvg_path_simplifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarklagodych%2Fsvg_path_simplifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarklagodych%2Fsvg_path_simplifier/lists"}