fix(visualizer): do not close window when path has finished moving

This commit is contained in:
2025-04-12 22:44:44 +02:00
parent 3a49f8dfae
commit 0e4aa06650

View File

@@ -39,27 +39,27 @@ class Visualizer:
self.screen.fill((0, 0, 0))
pos = self.positions[self.idx]
x, y, z = self._transform_coordinates(pos)
if self.prev_z < 0 and z < 0:
self.drawn_lines.append((self.prev_x, self.prev_y, x, y))
elif z > 0:
self.travel_moves.append((self.prev_x, self.prev_y, x, y))
if self.idx < len(self.positions):
pos = self.positions[self.idx]
x, y, z = self._transform_coordinates(pos)
if self.prev_z < 0 and z < 0:
self.drawn_lines.append((self.prev_x, self.prev_y, x, y))
elif z > 0:
self.travel_moves.append((self.prev_x, self.prev_y, x, y))
self.prev_x, self.prev_y, self.prev_z = x, y, z
# Draw the current position
pygame.draw.circle(self.screen, (255, 0, 0), (int(x), int(y)), 5)
self.idx += 1
# Draw travel moves
for travel_move in self.travel_moves:
x1, y1, x2, y2 = travel_move
# Draw a line from the previous position to the current position
pygame.draw.line(self.screen, (0, 0, 255), (int(x1), int(y1)), (int(x2), int(y2)), 2)
# Draw drawn lines
for drawn_line in self.drawn_lines:
x1, y1, x2, y2 = drawn_line
# Draw a line from the previous position to the current position
pygame.draw.line(self.screen, (255, 255, 255), (int(x1), int(y1)), (int(x2), int(y2)), 2)
self.prev_x, self.prev_y, self.prev_z = x, y, z
# Draw the current position
pygame.draw.circle(self.screen, (255, 0, 0), (int(x), int(y)), 5)
self.idx += 1
if self.idx >= len(self.positions):
running = False
pygame.display.flip()
self.clock.tick(10)
self.clock.tick(60)