summaryrefslogtreecommitdiff
path: root/lib/elements/utils.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2020-05-16 23:01:00 +0200
committerGitHub <noreply@github.com>2020-05-16 23:01:00 +0200
commita308db7ae152626c84ade069e307864a7e7e6213 (patch)
tree3af8a13562021796743378d16a1e7cc725ac75e4 /lib/elements/utils.py
parent4e950332419743dcbaf661fdda1f7c7970241d93 (diff)
support svg objects (#643)
Diffstat (limited to 'lib/elements/utils.py')
-rw-r--r--lib/elements/utils.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/elements/utils.py b/lib/elements/utils.py
index 5c71de2e..4719a5ff 100644
--- a/lib/elements/utils.py
+++ b/lib/elements/utils.py
@@ -1,40 +1,49 @@
-
from ..commands import is_command
-from ..svg.tags import SVG_POLYLINE_TAG, SVG_PATH_TAG
-
+from ..svg.tags import (EMBROIDERABLE_TAGS, SVG_IMAGE_TAG, SVG_POLYLINE_TAG,
+ SVG_TEXT_TAG)
from .auto_fill import AutoFill
+from .clone import Clone, is_clone
from .element import EmbroideryElement
from .fill import Fill
+from .image import ImageObject
from .polyline import Polyline
from .satin_column import SatinColumn
from .stroke import Stroke
+from .text import TextObject
-def node_to_elements(node):
+def node_to_elements(node): # noqa: C901
if node.tag == SVG_POLYLINE_TAG:
return [Polyline(node)]
- elif node.tag == SVG_PATH_TAG:
+
+ elif is_clone(node):
+ return [Clone(node)]
+
+ elif node.tag in EMBROIDERABLE_TAGS:
element = EmbroideryElement(node)
if element.get_boolean_param("satin_column") and element.get_style("stroke"):
return [SatinColumn(node)]
else:
elements = []
-
- if element.get_style("fill", "black"):
+ if element.get_style("fill", 'black') and not element.get_style('fill-opacity', 1) == "0":
if element.get_boolean_param("auto_fill", True):
elements.append(AutoFill(node))
else:
elements.append(Fill(node))
-
if element.get_style("stroke"):
if not is_command(element.node):
elements.append(Stroke(node))
-
if element.get_boolean_param("stroke_first", False):
elements.reverse()
-
return elements
+
+ elif node.tag == SVG_IMAGE_TAG:
+ return [ImageObject(node)]
+
+ elif node.tag == SVG_TEXT_TAG:
+ return [TextObject(node)]
+
else:
return []