summaryrefslogtreecommitdiff
path: root/lib/svg
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-06-21 15:41:06 -0400
committerLex Neva <github.com@lexneva.name>2018-06-21 15:41:06 -0400
commite29096ee138bd674e96a369a853d75eb7c919823 (patch)
tree963188c1d0ec3fa010fe353e2d97be64b6856066 /lib/svg
parentc8fe52f136c77906741fdab7093942eeb363a209 (diff)
add commands framework
Diffstat (limited to 'lib/svg')
-rw-r--r--lib/svg/__init__.py1
-rw-r--r--lib/svg/path.py20
-rw-r--r--lib/svg/tags.py5
3 files changed, 26 insertions, 0 deletions
diff --git a/lib/svg/__init__.py b/lib/svg/__init__.py
index 1895bba4..50543b1b 100644
--- a/lib/svg/__init__.py
+++ b/lib/svg/__init__.py
@@ -1,2 +1,3 @@
from .svg import color_block_to_point_lists, render_stitch_plan
from .units import *
+from .path import apply_transforms
diff --git a/lib/svg/path.py b/lib/svg/path.py
new file mode 100644
index 00000000..a8012774
--- /dev/null
+++ b/lib/svg/path.py
@@ -0,0 +1,20 @@
+import simpletransform
+import cubicsuperpath
+
+from .units import get_viewbox_transform
+
+def apply_transforms(path, 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)
+
+ # add in the transform implied by the viewBox
+ viewbox_transform = get_viewbox_transform(node.getroottree().getroot())
+ transform = simpletransform.composeTransform(viewbox_transform, transform)
+
+ # apply the combined transform to this node's path
+ simpletransform.applyTransformToPath(transform, path)
+
+ return path
diff --git a/lib/svg/tags.py b/lib/svg/tags.py
index fee59957..5488608c 100644
--- a/lib/svg/tags.py
+++ b/lib/svg/tags.py
@@ -5,8 +5,13 @@ SVG_PATH_TAG = inkex.addNS('path', 'svg')
SVG_POLYLINE_TAG = inkex.addNS('polyline', 'svg')
SVG_DEFS_TAG = inkex.addNS('defs', 'svg')
SVG_GROUP_TAG = inkex.addNS('g', 'svg')
+SVG_SYMBOL_TAG = inkex.addNS('symbol', 'svg')
+SVG_USE_TAG = inkex.addNS('use', 'svg')
INKSCAPE_LABEL = inkex.addNS('label', 'inkscape')
INKSCAPE_GROUPMODE = inkex.addNS('groupmode', 'inkscape')
+CONNECTION_START = inkex.addNS('connection-start', 'inkscape')
+CONNECTION_END = inkex.addNS('connection-end', 'inkscape')
+XLINK_HREF = inkex.addNS('href', 'xlink')
EMBROIDERABLE_TAGS = (SVG_PATH_TAG, SVG_POLYLINE_TAG)