summaryrefslogtreecommitdiff
path: root/lib/svg
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2020-04-25 14:45:27 +0200
committerGitHub <noreply@github.com>2020-04-25 14:45:27 +0200
commit319905087661bc44a560afff6c574b6545d21115 (patch)
tree249f7c5ff6f023df1a1bdd3933b7bc0377232658 /lib/svg
parent1d3b89111e627b3662a7ec2749bb3dcfe694be66 (diff)
Namespaced Attributes (#657)
Diffstat (limited to 'lib/svg')
-rw-r--r--lib/svg/rendering.py8
-rw-r--r--lib/svg/tags.py59
2 files changed, 63 insertions, 4 deletions
diff --git a/lib/svg/rendering.py b/lib/svg/rendering.py
index 2711f12a..5860ceef 100644
--- a/lib/svg/rendering.py
+++ b/lib/svg/rendering.py
@@ -5,10 +5,11 @@ import simplepath
import simplestyle
import simpletransform
-from .tags import INKSCAPE_GROUPMODE, INKSCAPE_LABEL, SVG_DEFS_TAG, SVG_GROUP_TAG, SVG_PATH_TAG
-from .units import PIXELS_PER_MM, get_viewbox_transform
from ..i18n import _
from ..utils import Point, cache
+from .tags import (INKSCAPE_GROUPMODE, INKSCAPE_LABEL, INKSTITCH_ATTRIBS,
+ SVG_DEFS_TAG, SVG_GROUP_TAG, SVG_PATH_TAG)
+from .units import PIXELS_PER_MM, get_viewbox_transform
# The stitch vector path looks like this:
# _______
@@ -198,6 +199,7 @@ def color_block_to_paths(color_block, svg, destination, visual_commands):
add_commands(Stroke(destination[-1]), ["trim"])
color = color_block.color.visible_on_white.to_hex_str()
+
path = inkex.etree.Element(SVG_PATH_TAG, {
'style': simplestyle.formatStyle({
'stroke': color,
@@ -206,7 +208,7 @@ def color_block_to_paths(color_block, svg, destination, visual_commands):
}),
'd': "M" + " ".join(" ".join(str(coord) for coord in point) for point in point_list),
'transform': get_correction_transform(svg),
- 'embroider_manual_stitch': 'true'
+ INKSTITCH_ATTRIBS['manual_stitch']: 'true'
})
destination.append(path)
diff --git a/lib/svg/tags.py b/lib/svg/tags.py
index 55af113a..3e444513 100644
--- a/lib/svg/tags.py
+++ b/lib/svg/tags.py
@@ -1,5 +1,6 @@
import inkex
+
# This is used below and added to the document in ../extensions/base.py.
inkex.NSS['inkstitch'] = 'http://inkstitch.org/namespace'
@@ -13,15 +14,71 @@ SVG_GROUP_TAG = inkex.addNS('g', 'svg')
SVG_SYMBOL_TAG = inkex.addNS('symbol', 'svg')
SVG_USE_TAG = inkex.addNS('use', 'svg')
+EMBROIDERABLE_TAGS = (SVG_PATH_TAG, SVG_POLYLINE_TAG)
+
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')
CONNECTOR_TYPE = inkex.addNS('connector-type', 'inkscape')
+
XLINK_HREF = inkex.addNS('href', 'xlink')
+
SODIPODI_NAMEDVIEW = inkex.addNS('namedview', 'sodipodi')
SODIPODI_GUIDE = inkex.addNS('guide', 'sodipodi')
SODIPODI_ROLE = inkex.addNS('role', 'sodipodi')
+
INKSTITCH_LETTERING = inkex.addNS('lettering', 'inkstitch')
-EMBROIDERABLE_TAGS = (SVG_PATH_TAG, SVG_POLYLINE_TAG)
+INKSTITCH_ATTRIBS = {}
+# Fill
+inkstitch_attribs = [
+ 'ties',
+ 'trim_after',
+ 'stop_after',
+ # fill
+ 'angle',
+ 'auto_fill',
+ 'expand_mm',
+ 'fill_underlay',
+ 'fill_underlay_angle',
+ 'fill_underlay_inset_mm',
+ 'fill_underlay_max_stitch_length_mm',
+ 'fill_underlay_row_spacing_mm',
+ 'fill_underlay_skip_last',
+ 'max_stitch_length_mm',
+ 'row_spacing_mm',
+ 'end_row_spacing_mm',
+ 'skip_last',
+ 'staggers',
+ 'underlay_underpath',
+ 'underpath',
+ 'flip',
+ 'expand_mm',
+ # stroke
+ 'manual_stitch',
+ 'bean_stitch_repeats',
+ 'repeats',
+ 'running_stitch_length_mm',
+ # satin column
+ 'satin_column',
+ 'satin_column',
+ 'running_stitch_length_mm',
+ 'center_walk_underlay',
+ 'center_walk_underlay_stitch_length_mm',
+ 'contour_underlay',
+ 'contour_underlay_stitch_length_mm',
+ 'contour_underlay_inset_mm',
+ 'zigzag_underlay',
+ 'zigzag_spacing_mm',
+ 'zigzag_underlay_inset_mm',
+ 'zigzag_underlay_spacing_mm',
+ 'e_stitch',
+ 'pull_compensation_mm',
+ 'stroke_first',
+ # Legacy
+ 'embroider_trim_after',
+ 'embroider_stop_after'
+ ]
+for attrib in inkstitch_attribs:
+ INKSTITCH_ATTRIBS[attrib] = inkex.addNS(attrib, 'inkstitch')