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.py | |
| parent | 8fc42628e285160f8f747772b6d5674a1bf23a09 (diff) | |
StitchGroups now contain only Stitches
Diffstat (limited to 'lib/stitch_plan/stitch.py')
| -rw-r--r-- | lib/stitch_plan/stitch.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/stitch_plan/stitch.py b/lib/stitch_plan/stitch.py index ea4423fa..f163d09c 100644 --- a/lib/stitch_plan/stitch.py +++ b/lib/stitch_plan/stitch.py @@ -4,13 +4,25 @@ # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. from ..utils.geometry import Point +from copy import deepcopy class Stitch(Point): """A stitch is a Point with extra information telling how to sew it.""" def __init__(self, x, y=None, color=None, jump=False, stop=False, trim=False, color_change=False, tie_modus=0, no_ties=False, tags=None): - Point.__init__(self, x, y) + if isinstance(x, Stitch): + # Allow creating a Stitch from another Stitch. Attributes passed as + # arguments will override any existing attributes. + vars(self).update(deepcopy(vars(x))) + elif isinstance(x, Point): + # Allow creating a Stitch from a Point + point = x + self.x = point.x + self.y = point.y + else: + Point.__init__(self, x, y) + self.color = color self.jump = jump self.trim = trim @@ -22,12 +34,6 @@ class Stitch(Point): self.add_tags(tags or []) - # Allow creating a Stitch from a Point - if isinstance(x, Point): - point = x - self.x = point.x - self.y = point.y - def __repr__(self): return "Stitch(%s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.x, self.y, |
