From 4c1f1bc2bbf9277e399dc8ddbed5c0d81d930a34 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 20 Mar 2019 20:45:29 -0400 Subject: tidy up start/end travel code --- lib/stitches/auto_fill.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/stitches/auto_fill.py') diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py index 8435d156..2414e937 100644 --- a/lib/stitches/auto_fill.py +++ b/lib/stitches/auto_fill.py @@ -360,13 +360,14 @@ def find_stitch_path(graph, travel_graph, starting_point=None, ending_point=None if starting_node is not ending_node: path.insert(0, PathEdge((starting_node, ending_node), key="initial")) + # If the starting and/or ending point falls far away from the end of a row + # of stitches (like can happen at the top of a square), then we need to + # add travel stitch to that point. real_start = nearest_node(travel_graph, starting_point) - if real_start != starting_node: - path.insert(0, PathEdge((real_start, starting_node), key="outline")) + path.insert(0, PathEdge((real_start, starting_node), key="outline")) real_end = nearest_node(travel_graph, ending_point) - if real_end != ending_node: - path.append(PathEdge((ending_node, real_end), key="outline")) + path.append(PathEdge((ending_node, real_end), key="outline")) return path -- cgit v1.2.3