summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
Diffstat (limited to 'lib/elements')
-rw-r--r--lib/elements/element.py5
-rw-r--r--lib/elements/stroke.py8
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/elements/element.py b/lib/elements/element.py
index 300136dd..42f6c470 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -29,6 +29,10 @@ class Patch:
else:
raise TypeError("Patch can only be added to another Patch")
+ def __len__(self):
+ # This method allows `len(patch)` and `if patch:
+ return len(self.stitches)
+
def add_stitch(self, stitch):
self.stitches.append(stitch)
@@ -36,7 +40,6 @@ class Patch:
return Patch(self.color, self.stitches[::-1])
-
class Param(object):
def __init__(self, name, description, unit=None, values=[], type=None, group=None, inverse=False, default=None, tooltip=None, sort_index=0):
self.name = name
diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py
index 48662b6d..097b36bc 100644
--- a/lib/elements/stroke.py
+++ b/lib/elements/stroke.py
@@ -97,6 +97,11 @@ class Stroke(EmbroideryElement):
# TODO: use inkstitch.stitches.running_stitch
patch = Patch(color=self.color)
+
+ # can't stitch a single point
+ if len(emb_point_list) < 2:
+ return patch
+
p0 = emb_point_list[0]
rho = 0.0
side = 1
@@ -156,6 +161,7 @@ class Stroke(EmbroideryElement):
else:
patch = self.stroke_points(path, self.zigzag_spacing / 2.0, stroke_width=self.stroke_width)
- patches.append(patch)
+ if patch:
+ patches.append(patch)
return patches