summaryrefslogtreecommitdiff
path: root/lib/stitch_plan/ties.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-07-25 21:21:24 -0400
committerGitHub <noreply@github.com>2018-07-25 21:21:24 -0400
commitf1478556565f2e23150c86b17e6e170edc217d23 (patch)
tree4e652bde1122f44f360e140b696cb0eb81a7e9e1 /lib/stitch_plan/ties.py
parent82c06cceda54d559e78792e5284f3520908142ed (diff)
parent1bd7aa110a1b30a6c44f4d792b3c817e10234c07 (diff)
Merge pull request #234 from inkstitch/lexelby-integrate-pyembroidery
switch from libembroidery to pyembroidery
Diffstat (limited to 'lib/stitch_plan/ties.py')
-rw-r--r--lib/stitch_plan/ties.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/stitch_plan/ties.py b/lib/stitch_plan/ties.py
index 6d07ac71..573469f5 100644
--- a/lib/stitch_plan/ties.py
+++ b/lib/stitch_plan/ties.py
@@ -30,15 +30,16 @@ def add_tie_in(stitches, upcoming_stitches):
def add_ties(stitch_plan):
"""Add tie-off before and after trims, jumps, and color changes."""
+ need_tie_in = True
for color_block in stitch_plan:
- need_tie_in = True
new_stitches = []
for i, stitch in enumerate(color_block.stitches):
- # Tie before and after TRIMs, JUMPs, and color changes, but ignore
- # the fake color change introduced by a "STOP after" (see stop.py).
- is_special = stitch.trim or stitch.jump or (stitch.color_change and not stitch.stop)
+ is_special = stitch.trim or stitch.jump or stitch.color_change or stitch.stop
- if is_special and not need_tie_in:
+ # see stop.py for an explanation of the fake color change
+ is_fake = stitch.fake_color_change
+
+ if is_special and not is_fake and not need_tie_in:
add_tie_off(new_stitches)
new_stitches.append(stitch)
need_tie_in = True
@@ -49,7 +50,8 @@ def add_ties(stitch_plan):
else:
new_stitches.append(stitch)
- if not need_tie_in:
- add_tie_off(new_stitches)
-
color_block.replace_stitches(new_stitches)
+
+ if not need_tie_in:
+ # tie off at the end if we haven't already
+ add_tie_off(color_block.stitches)