summaryrefslogtreecommitdiff
path: root/lib/svg/svg.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/svg/svg.py')
-rw-r--r--lib/svg/svg.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/lib/svg/svg.py b/lib/svg/svg.py
index 48b1343a..b1cc91d9 100644
--- a/lib/svg/svg.py
+++ b/lib/svg/svg.py
@@ -1,4 +1,6 @@
-import simpletransform, simplestyle, inkex
+import simpletransform
+import simplestyle
+import inkex
from .units import get_viewbox_transform
from .tags import SVG_GROUP_TAG, INKSCAPE_LABEL, INKSCAPE_GROUPMODE, SVG_PATH_TAG, SVG_DEFS_TAG
@@ -11,13 +13,13 @@ def color_block_to_point_lists(color_block):
point_lists = [[]]
for stitch in color_block:
- if stitch.trim:
- if point_lists[-1]:
- point_lists.append([])
- continue
+ if stitch.trim:
+ if point_lists[-1]:
+ point_lists.append([])
+ continue
- if not stitch.jump and not stitch.color_change:
- point_lists[-1].append(stitch.as_tuple())
+ if not stitch.jump and not stitch.color_change:
+ point_lists[-1].append(stitch.as_tuple())
return point_lists
@@ -51,13 +53,14 @@ def color_block_to_realistic_stitches(color_block, svg):
'stroke': 'none',
'filter': 'url(#realistic-stitch-filter)'
}),
- 'd': realistic_stitch(start, point),
- 'transform': get_correction_transform(svg)
- }))
+ 'd': realistic_stitch(start, point),
+ 'transform': get_correction_transform(svg)
+ }))
start = point
return paths
+
def color_block_to_paths(color_block, svg):
paths = []
# We could emit just a single path with one subpath per point list, but
@@ -68,13 +71,13 @@ def color_block_to_paths(color_block, svg):
SVG_PATH_TAG,
{'style': simplestyle.formatStyle(
{'stroke': color,
- 'stroke-width': "0.4",
- 'fill': 'none'}),
- 'd': "M" + " ".join(" ".join(str(coord) for coord in point) for point in point_list),
- 'transform': get_correction_transform(svg),
- 'embroider_manual_stitch': 'true',
- 'embroider_trim_after': 'true',
- }))
+ 'stroke-width': "0.4",
+ 'fill': 'none'}),
+ 'd': "M" + " ".join(" ".join(str(coord) for coord in point) for point in point_list),
+ 'transform': get_correction_transform(svg),
+ 'embroider_manual_stitch': 'true',
+ 'embroider_trim_after': 'true',
+ }))
# no need to trim at the end of a thread color
if paths:
@@ -82,6 +85,7 @@ def color_block_to_paths(color_block, svg):
return paths
+
def render_stitch_plan(svg, stitch_plan, realistic=False):
layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']")
if layer is None: