From 8d41d0f9af0e5390dacdfa2a18e213955aef8ddf Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 30 Jul 2018 14:57:54 -0400 Subject: convert to satin extension --- lib/svg/path.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/svg/path.py') 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) -- cgit v1.2.3 From 5f14617a029060416fcaea8247c29aa326f4b77f Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 30 Jul 2018 16:03:27 -0400 Subject: choose better rung positions --- lib/svg/path.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/svg/path.py') diff --git a/lib/svg/path.py b/lib/svg/path.py index 00e2c269..52144332 100644 --- a/lib/svg/path.py +++ b/lib/svg/path.py @@ -15,8 +15,10 @@ 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()) -- cgit v1.2.3