summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-11-14 20:23:06 -0500
committerGitHub <noreply@github.com>2018-11-14 20:23:06 -0500
commitf5c85183d9c874fca806917e50992daea4101496 (patch)
treea2450e2e37a7d94625a917240e78eadc939fd65b /lib/elements
parent238ad843dd658de6c7afd5b8697c0e080b1cf965 (diff)
basic lettering (#344)
Can handle multiple lines of text and routes the stitching in alternating directions on each line.
Diffstat (limited to 'lib/elements')
-rw-r--r--lib/elements/__init__.py7
-rw-r--r--lib/elements/utils.py47
2 files changed, 51 insertions, 3 deletions
diff --git a/lib/elements/__init__.py b/lib/elements/__init__.py
index 22603217..5413ba04 100644
--- a/lib/elements/__init__.py
+++ b/lib/elements/__init__.py
@@ -1,6 +1,7 @@
+from auto_fill import AutoFill
from element import EmbroideryElement
+from fill import Fill
+from polyline import Polyline
from satin_column import SatinColumn
from stroke import Stroke
-from polyline import Polyline
-from fill import Fill
-from auto_fill import AutoFill
+from utils import node_to_elements, nodes_to_elements
diff --git a/lib/elements/utils.py b/lib/elements/utils.py
new file mode 100644
index 00000000..87dfa877
--- /dev/null
+++ b/lib/elements/utils.py
@@ -0,0 +1,47 @@
+
+from ..commands import is_command
+from ..svg.tags import SVG_POLYLINE_TAG, SVG_PATH_TAG
+
+from .auto_fill import AutoFill
+from .element import EmbroideryElement
+from .fill import Fill
+from .polyline import Polyline
+from .satin_column import SatinColumn
+from .stroke import Stroke
+
+
+def node_to_elements(node):
+ if node.tag == SVG_POLYLINE_TAG:
+ return [Polyline(node)]
+ elif node.tag == SVG_PATH_TAG:
+ element = EmbroideryElement(node)
+
+ if element.get_boolean_param("satin_column"):
+ return [SatinColumn(node)]
+ else:
+ elements = []
+
+ if element.get_style("fill", "black"):
+ 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
+ else:
+ return []
+
+
+def nodes_to_elements(nodes):
+ elements = []
+ for node in nodes:
+ elements.extend(node_to_elements(node))
+
+ return elements