diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-07-04 21:44:08 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-07-12 20:13:46 -0400 |
| commit | d9033be6fc4dcca4ee33f80a55f1ae4a7921be89 (patch) | |
| tree | b004cceb97de9f5d6c9339276c347a3bf770be9f /lib | |
| parent | 22102ee0e839b22668873c45756a3666d4d9cbff (diff) | |
refactor out logic to gather node's transforms
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/svg/__init__.py | 2 | ||||
| -rw-r--r-- | lib/svg/path.py | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/svg/__init__.py b/lib/svg/__init__.py index 50543b1b..8e846555 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 +from .path import apply_transforms, get_node_transform diff --git a/lib/svg/path.py b/lib/svg/path.py index a8012774..2d9c0ff3 100644 --- a/lib/svg/path.py +++ b/lib/svg/path.py @@ -4,6 +4,14 @@ import cubicsuperpath from .units import get_viewbox_transform def apply_transforms(path, node): + transform = get_node_transform(node) + + # apply the combined transform to this node's path + simpletransform.applyTransformToPath(transform, path) + + return path + +def get_node_transform(node): # start with the identity transform transform = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]] @@ -14,7 +22,4 @@ def apply_transforms(path, node): 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 + return transform |
