An SVG path editor
Project description
SVG Path Editor
This is a straight-forward port of 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.
Basic usage:
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.
The library this port is based on is licensed under the terms of the Apache License, Version 2.0, which is provided in LicenseYqnn.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file svg_path_editor-1.3.tar.gz.
File metadata
- Download URL: svg_path_editor-1.3.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e000b35b61a3e58f3dbfa0d94ab3e9de34cbdb364dd04aa08fb89f55f0740fa2
|
|
| MD5 |
0aaa3c6c7009ebb4d4a1c9b6753c8ac5
|
|
| BLAKE2b-256 |
5e55159df8279f8db03ba76d4a79179c1a1e6145ef49c6f5b9bde2eae048441c
|
File details
Details for the file svg_path_editor-1.3-py3-none-any.whl.
File metadata
- Download URL: svg_path_editor-1.3-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2a72b93f3b26dec287e46b02026ac2c89938f595fd76e95fcab75371bd3efb2
|
|
| MD5 |
0d75f3cb3e9fb88e682ab7ddc143516a
|
|
| BLAKE2b-256 |
f7a1bd243c576eb3d61742ed664a041a05ed0a6a81745db35ecbbe07cd1260ab
|