Skip to content

Commit

Permalink
Fix issue with rotated fill crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
Walnit committed Jan 21, 2025
1 parent 48ad8bf commit 75d188e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/turtlethread/fills.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, angle : str | int | float = "auto"):
self.angle = angle

def _fill_at_angle(self, turtle, points, angle, simulate=False):
print(points)
# Rotate the coordinates
rot_points = []
for x, y in points:
Expand Down Expand Up @@ -99,16 +100,21 @@ def _fill_at_angle(self, turtle, points, angle, simulate=False):

jump_stitches = 0
# Jump to start coordinate if needed
if abs(Vec2D(scanned_lines[0][0][0], scanned_lines[0][0][1]) - turtle.pos()) > 1:
print(scanned_lines)
start_idx = 0
while len(scanned_lines[start_idx]) < 1:
start_idx += 1

if abs(Vec2D(scanned_lines[start_idx][0][0], scanned_lines[start_idx][0][1]) - turtle.pos()) > 1:
with turtle.jump_stitch():
jump_stitches += 1
if not simulate: turtle.goto(scanned_lines[0][0])
if not simulate: turtle.goto(scanned_lines[start_idx][0])

no_fill_in_current_iteration_flag = False
while not no_fill_in_current_iteration_flag:
no_fill_in_current_iteration_flag = True
jump = False
for i in range(len(scanned_lines) - 1):
for i in range(start_idx, len(scanned_lines) - 1):
with turtle.direct_stitch():
if len(scanned_lines[i]) >= 2:
no_fill_in_current_iteration_flag = False
Expand Down

0 comments on commit 75d188e

Please sign in to comment.