diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2021-03-04 18:40:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-04 18:40:53 +0100 |
| commit | e84a86d4ac0caf29d6074728376ff0a594243fec (patch) | |
| tree | 888c79ed0094ba2916a1d329861a85515959913c /lib/svg/path.py | |
| parent | b39575a50191307b3b56eab6455626398eec6397 (diff) | |
Update for Inkscape 1.0 (#880)
* update for inkscape 1.0
* add about extension
* Build improvements for the inkscape1.0 branch (#985)
* zip: export real svg not stitch plan
* #411 and #726
* Tools for Font Creators (#1018)
* ignore very small holes in fills
* remove embroider (#1026)
* auto_fill: ignore shrink_or_grow if result is empty (#589)
* break apart: do not ignore small fills
Co-authored-by: Hagen Fritsch <rumpeltux-github@irgendwo.org>
Co-authored-by: Lex Neva <github.com@lexneva.name>
Diffstat (limited to 'lib/svg/path.py')
| -rw-r--r-- | lib/svg/path.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/svg/path.py b/lib/svg/path.py index cc4b8cbb..baa93443 100644 --- a/lib/svg/path.py +++ b/lib/svg/path.py @@ -1,8 +1,7 @@ -import cubicsuperpath import inkex -import simpletransform -from tags import SVG_GROUP_TAG, SVG_LINK_TAG +from lxml import etree +from .tags import SVG_GROUP_TAG, SVG_LINK_TAG from .units import get_viewbox_transform @@ -10,7 +9,7 @@ def apply_transforms(path, node): transform = get_node_transform(node) # apply the combined transform to this node's path - simpletransform.applyTransformToPath(transform, path) + path = path.transform(transform) return path @@ -21,7 +20,7 @@ def compose_parent_transforms(node, mat): trans = node.get('transform') if trans: - mat = simpletransform.composeTransform(simpletransform.parseTransform(trans), mat) + mat = inkex.transforms.Transform(trans) * mat if node.getparent() is not None: if node.getparent().tag in [SVG_GROUP_TAG, SVG_LINK_TAG]: mat = compose_parent_transforms(node.getparent(), mat) @@ -29,20 +28,22 @@ def compose_parent_transforms(node, mat): def get_node_transform(node): + """ + if getattr(node, "composed_transform", None): + return node.composed_transform() + """ + # start with the identity transform - transform = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]] + transform = inkex.transforms.Transform([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) # this if is because sometimes inkscape likes to create paths outside of a layer?! if node.getparent() is not None: # combine this node's transform with all parent groups' transforms transform = compose_parent_transforms(node, transform) - if node.get('id', '').startswith('clone_'): - transform = simpletransform.parseTransform(node.get('transform', '')) - # add in the transform implied by the viewBox viewbox_transform = get_viewbox_transform(node.getroottree().getroot()) - transform = simpletransform.composeTransform(viewbox_transform, transform) + transform = viewbox_transform * transform return transform @@ -63,9 +64,9 @@ def get_correction_transform(node, child=False): # now invert it, so that we can position our objects in absolute # coordinates - transform = simpletransform.invertTransform(transform) + transform = -transform - return simpletransform.formatTransform(transform) + return str(transform) def line_strings_to_csp(line_strings): @@ -90,6 +91,6 @@ def point_lists_to_csp(point_lists): def line_strings_to_path(line_strings): csp = line_strings_to_csp(line_strings) - return inkex.etree.Element("path", { - "d": cubicsuperpath.formatPath(csp) + return etree.Element("path", { + "d": str(inkex.paths.CubicSuperPath(csp)) }) |
