summaryrefslogtreecommitdiff
path: root/lib/marker.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/marker.py')
-rw-r--r--lib/marker.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/marker.py b/lib/marker.py
index 977475b0..91a5862f 100644
--- a/lib/marker.py
+++ b/lib/marker.py
@@ -6,10 +6,9 @@
from copy import deepcopy
from os import path
+from inkex import NSS, Style, load_svg
from shapely import geometry as shgeo
-import inkex
-
from .svg.tags import EMBROIDERABLE_TAGS
from .utils import cache, get_bundled_dir
@@ -26,18 +25,16 @@ def ensure_marker(svg, marker):
def _marker_svg():
marker_path = path.join(get_bundled_dir("symbols"), "marker.svg")
with open(marker_path) as marker_file:
- return inkex.load_svg(marker_file).getroot()
+ return load_svg(marker_file).getroot()
def set_marker(node, position, marker):
ensure_marker(node.getroottree().getroot(), marker)
# attach marker to node
- style = node.get('style') or ''
- style = style.split(";")
- style = [i for i in style if not i.startswith('marker-%s' % position)]
- style.append('marker-%s:url(#inkstitch-%s-marker)' % (position, marker))
- node.set('style', ";".join(style))
+ style = node.style
+ style += Style(f'marker-{ position }:url(#inkstitch-{ marker }-marker)')
+ node.set('style', style)
def get_marker_elements(node, marker, get_fills=True, get_strokes=True, get_satins=False):
@@ -52,7 +49,7 @@ def get_marker_elements(node, marker, get_fills=True, get_strokes=True, get_sati
# do not close marker-start:url(
# if the marker group has been copied and pasted in Inkscape it may have been duplicated with an updated id (e.g. -4)
xpath = "./parent::svg:g/*[contains(@style, 'marker-start:url(#inkstitch-%s-marker')]" % marker
- markers = node.xpath(xpath, namespaces=inkex.NSS)
+ markers = node.xpath(xpath, namespaces=NSS)
for marker in markers:
if marker.tag not in EMBROIDERABLE_TAGS:
continue