svg-path-editor


Namesvg-path-editor JSON
Version 1.3.1 PyPI version JSON
download
home_pageNone
SummaryAn SVG path editor
upload_time2025-10-11 16:01:42
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseNone
keywords svg drawing vector
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SVG Path Editor

This is a straight-forward port of [`svg-path-editor-lib`](https://www.npmjs.com/package/svg-path-editor-lib) 1.0.3 to Python with minor changes to make the interface more Pythonic.
Despite these changes, most operations still operate in-place, and changing this behaviour is beyond the scope of this port.

This package is available on PyPI and can be installed using `pip`:

```sh
pip install svg-path-editor
```

Basic usage:

```python
from svg_path_editor import SvgPath, change_path_origin, optimize_path, reverse_path

path = SvgPath("M-15 14s5 7.5 15 7.5 15-7.5 15-7.5")
# M -15 14 s 5 7.5 15 7.5 s 15 -7.5 15 -7.5
print(path)
# M-15 14s5 7.5 15 7.5 15-7.5 15-7.5
# default: decimals=None, minify=False
print(path.as_string(decimals=1, minify=True))

# Transformations
# M -30 28 s 10 15 30 15 s 30 -15 30 -15
print(path.scale(kx=2, ky=2))
# M -29 28.5 s 10 15 30 15 s 30 -15 30 -15
print(path.translate(dx=1, dy=0.5))
# M -28.5 -29 s -15 10 -15 30 s 15 30 15 30
print(path.rotate(ox=0, oy=0, degrees=90).as_string(decimals=2))

# Make absolute/relative
# M -28.5 -29 S -43.5 -19 -43.5 1 S -28.5 31 -28.5 31
print(path.set_relative(False))
# m -28.5 -29 s -15 10 -15 30 s 15 30 15 30
print(path.set_relative(True))

# Reverse path
reverse_path(path)
# M -28.5 31 S -43.5 21 -43.5 1 S -28.5 -29 -28.5 -29
print(path)

# Change origin of path
change_path_origin(path, 2)
# M -43.5 1 C -43.5 -19 -28.5 -29 -28.5 -29 M -28.5 31 S -43.5 21 -43.5 1
print(path)

# Optimized path
optimize_path(
    path,
    # default `False`
    remove_useless_commands=True,
    # default `False`
    use_shorthands=True,
    # default `False`
    use_horizontal_and_vertical_lines=True,
    # default `False`
    use_relative_absolute=True,
    # default `False`
    use_reverse=True,
    # default `False`, may be destructive for stroked paths
    remove_orphan_dots=True,
    # default `False`, may be destructive for stroked paths
    use_close_path=True,
)
# M -28.5 31 s -15 -10 -15 -30 s 15 -30 15 -30
print(path)
# M-28.5 31s-15-10-15-30 15-30 15-30
print(path.as_string(minify=True))
```

# License

This port is licensed under the terms of the Mozilla Public Licence 2.0, which is provided in [`License`](License).
The library this port is based on is licensed under the terms of the Apache License, Version 2.0, which is provided in [`LicenseYqnn`](LicenseYqnn).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "svg-path-editor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "svg, drawing, vector",
    "author": null,
    "author_email": "Kurt B\u00f6hm <kurbo96@gmail.de>",
    "download_url": "https://files.pythonhosted.org/packages/c9/78/bbabe8f017a34265137dc0ce441d8457b95c13e8630ac1c9101ce62fc05c/svg_path_editor-1.3.1.tar.gz",
    "platform": null,
    "description": "# SVG Path Editor\n\nThis is a straight-forward port of [`svg-path-editor-lib`](https://www.npmjs.com/package/svg-path-editor-lib) 1.0.3 to Python with minor changes to make the interface more Pythonic.\nDespite these changes, most operations still operate in-place, and changing this behaviour is beyond the scope of this port.\n\nThis package is available on PyPI and can be installed using `pip`:\n\n```sh\npip install svg-path-editor\n```\n\nBasic usage:\n\n```python\nfrom svg_path_editor import SvgPath, change_path_origin, optimize_path, reverse_path\n\npath = SvgPath(\"M-15 14s5 7.5 15 7.5 15-7.5 15-7.5\")\n# M -15 14 s 5 7.5 15 7.5 s 15 -7.5 15 -7.5\nprint(path)\n# M-15 14s5 7.5 15 7.5 15-7.5 15-7.5\n# default: decimals=None, minify=False\nprint(path.as_string(decimals=1, minify=True))\n\n# Transformations\n# M -30 28 s 10 15 30 15 s 30 -15 30 -15\nprint(path.scale(kx=2, ky=2))\n# M -29 28.5 s 10 15 30 15 s 30 -15 30 -15\nprint(path.translate(dx=1, dy=0.5))\n# M -28.5 -29 s -15 10 -15 30 s 15 30 15 30\nprint(path.rotate(ox=0, oy=0, degrees=90).as_string(decimals=2))\n\n# Make absolute/relative\n# M -28.5 -29 S -43.5 -19 -43.5 1 S -28.5 31 -28.5 31\nprint(path.set_relative(False))\n# m -28.5 -29 s -15 10 -15 30 s 15 30 15 30\nprint(path.set_relative(True))\n\n# Reverse path\nreverse_path(path)\n# M -28.5 31 S -43.5 21 -43.5 1 S -28.5 -29 -28.5 -29\nprint(path)\n\n# Change origin of path\nchange_path_origin(path, 2)\n# M -43.5 1 C -43.5 -19 -28.5 -29 -28.5 -29 M -28.5 31 S -43.5 21 -43.5 1\nprint(path)\n\n# Optimized path\noptimize_path(\n    path,\n    # default `False`\n    remove_useless_commands=True,\n    # default `False`\n    use_shorthands=True,\n    # default `False`\n    use_horizontal_and_vertical_lines=True,\n    # default `False`\n    use_relative_absolute=True,\n    # default `False`\n    use_reverse=True,\n    # default `False`, may be destructive for stroked paths\n    remove_orphan_dots=True,\n    # default `False`, may be destructive for stroked paths\n    use_close_path=True,\n)\n# M -28.5 31 s -15 -10 -15 -30 s 15 -30 15 -30\nprint(path)\n# M-28.5 31s-15-10-15-30 15-30 15-30\nprint(path.as_string(minify=True))\n```\n\n# License\n\nThis port is licensed under the terms of the Mozilla Public Licence 2.0, which is provided in [`License`](License).\nThe library this port is based on is licensed under the terms of the Apache License, Version 2.0, which is provided in [`LicenseYqnn`](LicenseYqnn).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An SVG path editor",
    "version": "1.3.1",
    "project_urls": {
        "Repository": "https://github.com/KurtBoehm/svg_path_editor"
    },
    "split_keywords": [
        "svg",
        " drawing",
        " vector"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "da4b76d70dbd9e2394bb26d26e3d2deb2343acd9a0b0d852718cd6171508b1a6",
                "md5": "a532b0670764ac40fee2d3bafcd0ac6b",
                "sha256": "ab253f685062cbef8ccd640925b49f702aa61fd1fca1a5a4ee4429efa302cc0d"
            },
            "downloads": -1,
            "filename": "svg_path_editor-1.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a532b0670764ac40fee2d3bafcd0ac6b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 18616,
            "upload_time": "2025-10-11T16:01:40",
            "upload_time_iso_8601": "2025-10-11T16:01:40.812439Z",
            "url": "https://files.pythonhosted.org/packages/da/4b/76d70dbd9e2394bb26d26e3d2deb2343acd9a0b0d852718cd6171508b1a6/svg_path_editor-1.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c978bbabe8f017a34265137dc0ce441d8457b95c13e8630ac1c9101ce62fc05c",
                "md5": "b52400c928e780326266a36a8e8bc673",
                "sha256": "03d2e23c92616f9a417bb28c035b9d41640c4526cc2a2381b9c6ce371de9fd4e"
            },
            "downloads": -1,
            "filename": "svg_path_editor-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b52400c928e780326266a36a8e8bc673",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 16570,
            "upload_time": "2025-10-11T16:01:42",
            "upload_time_iso_8601": "2025-10-11T16:01:42.046615Z",
            "url": "https://files.pythonhosted.org/packages/c9/78/bbabe8f017a34265137dc0ce441d8457b95c13e8630ac1c9101ce62fc05c/svg_path_editor-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-11 16:01:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "KurtBoehm",
    "github_project": "svg_path_editor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "svg-path-editor"
}
        
Elapsed time: 3.73894s