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 e560497fe6
commit a6d67790e4

View File

@@ -39,27 +39,27 @@ class Visualizer:
self.screen.fill((0, 0, 0)) self.screen.fill((0, 0, 0))
pos = self.positions[self.idx] if self.idx < len(self.positions):
x, y, z = self._transform_coordinates(pos) pos = self.positions[self.idx]
if self.prev_z < 0 and z < 0: x, y, z = self._transform_coordinates(pos)
self.drawn_lines.append((self.prev_x, self.prev_y, x, y)) if self.prev_z < 0 and z < 0:
elif z > 0: self.drawn_lines.append((self.prev_x, self.prev_y, x, y))
self.travel_moves.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 # Draw travel moves
for travel_move in self.travel_moves: for travel_move in self.travel_moves:
x1, y1, x2, y2 = travel_move 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) 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: for drawn_line in self.drawn_lines:
x1, y1, x2, y2 = drawn_line 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) 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() pygame.display.flip()
self.clock.tick(10) self.clock.tick(60)