From 77d6b78f92d507cdb22e744b1c93712fc6d67e5b Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 28 May 2018 20:06:26 -0400 Subject: fix STOP handling Apparently STOP codes (a.k.a. color changes) should be by themselves, not attached to another stitch. To add a STOP code at a given stitch, we should clone the stitch and then set the STOP command on the new stitch. --- lib/stitch_plan/stitch_plan.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/stitch_plan/stitch_plan.py') diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index 570a7645..fef7f61d 100644 --- a/lib/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -39,8 +39,12 @@ def patches_to_stitch_plan(patches, collapse_len=3.0 * PIXELS_PER_MM): color_block.add_stitch(patch.stitches[0].x, patch.stitches[0].y, jump=True) else: - # add a color change - color_block.add_stitch(color_block.last_stitch.x, color_block.last_stitch.y, stop=True) + # add a color change (only if the last stitch wasn't a "STOP after") + if not color_block.last_stitch.stop: + stitch = color_block.last_stitch.copy() + stitch.stop = True + color_block.add_stitch(stitch) + color_block = stitch_plan.new_color_block() color_block.color = patch.color -- cgit v1.2.3