summaryrefslogtreecommitdiff
path: root/lib/stitch_plan/stitch_group.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stitch_plan/stitch_group.py')
-rw-r--r--lib/stitch_plan/stitch_group.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/stitch_plan/stitch_group.py b/lib/stitch_plan/stitch_group.py
index d1e6bae7..548ad892 100644
--- a/lib/stitch_plan/stitch_group.py
+++ b/lib/stitch_plan/stitch_group.py
@@ -1,5 +1,8 @@
+from .stitch import Stitch
+
+
class StitchGroup:
- """A collection of Stitch objects with attached instructions.
+ """A collection of Stitch objects with attached instructions and attributes.
StitchGroups will later be combined to make ColorBlocks, which in turn are
combined to make a StitchPlan. Jump stitches are allowed between
@@ -11,11 +14,14 @@ class StitchGroup:
def __init__(self, color=None, stitches=None, trim_after=False, stop_after=False, tie_modus=0, stitch_as_is=False):
self.color = color
- self.stitches = stitches or []
self.trim_after = trim_after
self.stop_after = stop_after
self.tie_modus = tie_modus
self.stitch_as_is = stitch_as_is
+ self.stitches = []
+
+ if stitches:
+ self.add_stitches(stitches)
def __add__(self, other):
if isinstance(other, StitchGroup):
@@ -27,7 +33,15 @@ class StitchGroup:
# This method allows `len(patch)` and `if patch:
return len(self.stitches)
+ def add_stitches(self, stitches):
+ for stitch in stitches:
+ self.add_stitch(stitch)
+
def add_stitch(self, stitch):
+ if not isinstance(stitch, Stitch):
+ # probably a Point
+ stitch = Stitch(stitch)
+
self.stitches.append(stitch)
def reverse(self):