diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-07-15 22:53:18 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-07-25 21:17:58 -0400 |
| commit | 2cd4963d09ef78dd25a7401cc47a69474d7fa952 (patch) | |
| tree | b9d7e8433694138e30daa76ff2f6206e39a5dd6c /lib/stitch_plan/ties.py | |
| parent | dbcbf7cff1c8e76a2715d939818124c33cb5fa1e (diff) | |
adjust stitch plan code for pyembroidery
Diffstat (limited to 'lib/stitch_plan/ties.py')
| -rw-r--r-- | lib/stitch_plan/ties.py | 18 |
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) |
