summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-07-23 20:15:49 -0400
committerLex Neva <github.com@lexneva.name>2018-07-25 21:17:58 -0400
commite0cecd6fa444e3b7ea2391ce4f2953ae9fd5f3fa (patch)
tree594303377f13fc8e33eaefceb60b26f2ace033e3
parent5ce8df77a07b11b902792d299d4cb89b6951ccd8 (diff)
fix a couple crashes
-rw-r--r--lib/stitch_plan/stitch_plan.py4
-rw-r--r--lib/svg/svg.py3
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py
index 0fa87d71..a7cd60e8 100644
--- a/lib/stitch_plan/stitch_plan.py
+++ b/lib/stitch_plan/stitch_plan.py
@@ -45,6 +45,10 @@ def patches_to_stitch_plan(patches, collapse_len=3.0 * PIXELS_PER_MM):
color_block.add_stitch(stop=True)
color_block = stitch_plan.new_color_block(color_block.color)
+ if len(color_block) == 0:
+ # last block ended in a stop, so now we have an empty block
+ del stitch_plan.color_blocks[-1]
+
stitch_plan.filter_duplicate_stitches()
stitch_plan.add_ties()
diff --git a/lib/svg/svg.py b/lib/svg/svg.py
index 5552abd8..48b1343a 100644
--- a/lib/svg/svg.py
+++ b/lib/svg/svg.py
@@ -37,6 +37,9 @@ def color_block_to_realistic_stitches(color_block, svg):
paths = []
for point_list in color_block_to_point_lists(color_block):
+ if not point_list:
+ continue
+
color = color_block.color.visible_on_white.darker.to_hex_str()
start = point_list[0]
for point in point_list[1:]: