Skip to main content

Python bindings to Inkscape\'s livarot library

Project description

Python 3 bindings to the inkscape libraries lib2geom and livarot.

Installation

manylinux whls have been published to pypi, there's likely a whl for your distro/python version at:

pip install pylivarot

On windows,

python3 setup.py bdist_wheel

should work in theory, but I currently have not gotten this working (boost is not configured right)

Usage

Declaring Path Vectors:

from pylivarot import py2geom

# using a path builder
_path_builder = py2geom.PathBuilder()
_path_builder.moveTo(py2geom.Point(0, 0))
_path_builder.lineTo(py2geom.Point(10, 20))
_path_builder.quadTo(py2geom.Point(10, 20), py2geom.Point(20, 50))
_path_builder.curveTo(py2geom.Point(10, 20), py2geom.Point(20, 50), py2geom.Point(40, 80))        
_path_builder.flush()
result = _path_builder.peek()

# using an SVG d string
diagonal_line = "M 0,0 L 3,3 z"
pv_diagonal_line = py2geom.parse_svg_path(diagonal_line) 

Format an SVG d string:

from pylivarot import py2geom

pv = py2geom.PathVector()
target_d = py2geom.write_svg_path(pv)

Apply a transform:

from pylivarot import py2geom

path_d =  "M 0,0 L 0,2 L 2,2 L 2,0 z"
pv_path = py2geom.parse_svg_path(path_d)
_affine = py2geom.Affine()
_affine *= py2geom.Translate(py2geom.Point(2, 4))
_affine *= py2geom.Rotate(3.14159/4.0) 
for _path in pv_path:
    for _curve in _path:
        _curve.transform(_affine)

Boolean operations

from pylivarot import py2geom, union, intersection, difference

path_v_a = py2geom.parse_svg_path("M 0,0 L 0,2 L 2,2 L 2,0 z")
path_v_b = py2geom.parse_svg_path("M 0.5,0.5 L 0.5,1.5 L 1.5,1.5 L 1.5,0.5 z")

union_pv = union(path_v_a, path_v_b)
inters_pv = intersection(path_v_a, path_v_b)
diff_pv = difference(path_v_a, path_v_b)

Path Vector Bounding box (also works on Paths)

from pylivarot import py2geom

opt_bbox = path_vector.boundsExact() # or pv.boundsFast()
bbox = py2geom.Rect(opt_bbox[py2geom.Dim2.X], opt_bbox[py2geom.Dim2.Y])
print(bbox.left(), bbox.right(), bbox.top(), bbox.bottom(), bbox.width(), bbox.height())

Inkscape's get_outline and get_outline_offset functionality

from pylivarot import py2geom, get_outline, get_outline_offset

outline = get_outline(path_vector)
outline_offset = get_outline_offset(path_vector, stroke_width)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pylivarot-1.0.1-cp310-cp310-manylinux_2_24_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.24+ x86-64

pylivarot-1.0.1-cp39-cp39-manylinux_2_24_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

pylivarot-1.0.1-cp38-cp38-manylinux_2_24_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.24+ x86-64

pylivarot-1.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.24+ x86-64

pylivarot-1.0.1-cp36-cp36m-manylinux_2_24_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.24+ x86-64

File details

Details for the file pylivarot-1.0.1-cp310-cp310-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pylivarot-1.0.1-cp310-cp310-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.10, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.1 requests/2.25.1 setuptools/33.1.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.5.3

File hashes

Hashes for pylivarot-1.0.1-cp310-cp310-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 06cb70f1b90abcccaadeea077cf2ec66c402b7e5b515f4c3402f2ab4a62ff0bf
MD5 fde412351c3a210b956018d042ca42c0
BLAKE2b-256 69294dce25533e261b3fba9e6c5fbe9fe430679253735941c834ec846b8a5000

See more details on using hashes here.

File details

Details for the file pylivarot-1.0.1-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pylivarot-1.0.1-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.1 requests/2.25.1 setuptools/33.1.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.5.3

File hashes

Hashes for pylivarot-1.0.1-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 6759adfd6167c70b34dc44f5fc4442a2ac66ea71ab4f3d0ce8b883fba88b5ee1
MD5 a0161a021d1e9e5faa609a761f2e1bc9
BLAKE2b-256 4d6385a9765a1b11403d965720deee1f07bc82f0deeb5b78931a932eab874edd

See more details on using hashes here.

File details

Details for the file pylivarot-1.0.1-cp38-cp38-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pylivarot-1.0.1-cp38-cp38-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.1 requests/2.25.1 setuptools/33.1.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.5.3

File hashes

Hashes for pylivarot-1.0.1-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 f2fedacec1fe86528eb2e31ed5c1da9e172637155cdbbcba9d3c6cc1b0d54876
MD5 9019d5d52ee7149efd9e3f688fb952ad
BLAKE2b-256 ed574eaf467bba4dfba007f2934c847e735a3ed59d26873672142e4e0fec0a54

See more details on using hashes here.

File details

Details for the file pylivarot-1.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pylivarot-1.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.1 requests/2.25.1 setuptools/33.1.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.5.3

File hashes

Hashes for pylivarot-1.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 395bdb5467d992560fb7b64c64815e6a61dd0f0b4a055220ee268fe3763e98b2
MD5 97ad1fe7489382f5708f126241a5b208
BLAKE2b-256 6e1d10bf58aa7d2512115714c7aff0003f29738a7aa9004351b5183ba56ea918

See more details on using hashes here.

File details

Details for the file pylivarot-1.0.1-cp36-cp36m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: pylivarot-1.0.1-cp36-cp36m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.1 requests/2.25.1 setuptools/33.1.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.5.3

File hashes

Hashes for pylivarot-1.0.1-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 9817d4ade6ec7b5211fc2a5186602f78920aa7efce14144bbe2c120c97d2591c
MD5 9955863380feb73068eea3daaf5e0b89
BLAKE2b-256 a968a536c32cd50c13fac027ceab8cdf51c0b54f3b6adfd1a2f888078a7ca6d3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page