diff options
| author | Lex Neva <github.com@lexneva.name> | 2021-08-07 12:00:56 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2021-08-07 12:01:07 -0400 |
| commit | 28e394b2ae7f4dabcc331d456103d4b3d0efae84 (patch) | |
| tree | 5234cf44b4d445d19683d7e7426fa033c105ec44 /lib/stitch_plan/stitch_group.py | |
| parent | 8fc42628e285160f8f747772b6d5674a1bf23a09 (diff) | |
StitchGroups now contain only Stitches
Diffstat (limited to 'lib/stitch_plan/stitch_group.py')
| -rw-r--r-- | lib/stitch_plan/stitch_group.py | 18 |
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): |
