summaryrefslogtreecommitdiff
path: root/lib/svg/path.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-08-05 20:35:21 -0400
committerGitHub <noreply@github.com>2018-08-05 20:35:21 -0400
commit3e37db9dec0222978f615f6d33874a31d76000c3 (patch)
tree499acace3107ba39a093c18f0debc6283c68ac63 /lib/svg/path.py
parent50f7589d682e060c8d12a6fd30822fbeb7f2212a (diff)
parenteebc8fdc1252a3206982c818685e50a4a75a4398 (diff)
Merge pull request #252 from inkstitch/lexelby-convert-to-satin
convert path to satin
Diffstat (limited to 'lib/svg/path.py')
-rw-r--r--lib/svg/path.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/svg/path.py b/lib/svg/path.py
index 2d9c0ff3..52144332 100644
--- a/lib/svg/path.py
+++ b/lib/svg/path.py
@@ -15,11 +15,30 @@ def get_node_transform(node):
# start with the identity transform
transform = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
- # combine this node's transform with all parent groups' transforms
- transform = simpletransform.composeParents(node, transform)
+ # 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 = simpletransform.composeParents(node, transform)
# add in the transform implied by the viewBox
viewbox_transform = get_viewbox_transform(node.getroottree().getroot())
transform = simpletransform.composeTransform(viewbox_transform, transform)
return transform
+
+def get_correction_transform(node):
+ """Get a transform to apply to new siblings of this SVG node"""
+
+ # if we want to place our new nodes in the same group/layer as this node,
+ # then we'll need to factor in the effects of any transforms set on
+ # the parents of this node.
+
+ # we can ignore the transform on the node itself since it won't apply
+ # to the objects we add
+ transform = get_node_transform(node.getparent())
+
+ # now invert it, so that we can position our objects in absolute
+ # coordinates
+ transform = simpletransform.invertTransform(transform)
+
+ return simpletransform.formatTransform(transform)