summaryrefslogtreecommitdiff
path: root/lib/svg
diff options
context:
space:
mode:
Diffstat (limited to 'lib/svg')
-rw-r--r--lib/svg/__init__.py2
-rw-r--r--lib/svg/path.py17
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/svg/__init__.py b/lib/svg/__init__.py
index 8e846555..429e6b5e 100644
--- a/lib/svg/__init__.py
+++ b/lib/svg/__init__.py
@@ -1,3 +1,3 @@
from .svg import color_block_to_point_lists, render_stitch_plan
from .units import *
-from .path import apply_transforms, get_node_transform
+from .path import apply_transforms, get_node_transform, get_correction_transform
diff --git a/lib/svg/path.py b/lib/svg/path.py
index 2d9c0ff3..00e2c269 100644
--- a/lib/svg/path.py
+++ b/lib/svg/path.py
@@ -23,3 +23,20 @@ def get_node_transform(node):
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)