Compare commits
2 Commits
d3fcba9ebc
...
3acbff18e7
| Author | SHA1 | Date | |
|---|---|---|---|
| 3acbff18e7 | |||
| ac709f9925 |
@@ -1,2 +1,3 @@
|
||||
pygame==2.6.1
|
||||
pygcode==0.2.1
|
||||
colorama==0.4.6
|
||||
3669
test/gothenburg.gcode
Normal file
3669
test/gothenburg.gcode
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,6 @@
|
||||
import pygame
|
||||
import sys
|
||||
from colorama import Fore, Style
|
||||
|
||||
class Visualizer:
|
||||
def __init__(self, positions : list[tuple[float, float, float]], screen_dimensions : tuple[int, int], gcode_size : tuple[float, float]):
|
||||
@@ -30,6 +32,26 @@ class Visualizer:
|
||||
self.screen = pygame.display.set_mode(self.screen_dimensions)
|
||||
self.clock = pygame.time.Clock()
|
||||
|
||||
def _print_status(self) -> None:
|
||||
normalized_x = self.prev_x / self.screen.get_width()
|
||||
normalized_y = self.prev_y / self.screen.get_height()
|
||||
pen_active = self.prev_z < 0
|
||||
|
||||
# Clear the terminal with ANSI code
|
||||
print("\033c", end="")
|
||||
|
||||
# X-axis bar
|
||||
x_bar = f"{Fore.GREEN}{'#'*int(normalized_x*100)}{Style.RESET_ALL}{' '*int((1.0-normalized_x)*100)}"
|
||||
print(f"X: |{x_bar}| {(normalized_x*100):.2f}%")
|
||||
|
||||
# Y-axis bar
|
||||
y_bar = f"{Fore.BLUE}{'#'*int(normalized_y*100)}{Style.RESET_ALL}{' '*int((1.0-normalized_y)*100)}"
|
||||
print(f"Y: |{y_bar}| {(normalized_y*100):.2f}%")
|
||||
|
||||
# Pen status
|
||||
pen_status = f"{Fore.GREEN}Active{Style.RESET_ALL}" if pen_active else f"{Fore.RED}Inactive{Style.RESET_ALL}"
|
||||
print(f"Pen: {pen_status}")
|
||||
|
||||
def visualize(self) -> None:
|
||||
running = True
|
||||
while running:
|
||||
@@ -61,5 +83,7 @@ class Visualizer:
|
||||
x1, y1, x2, y2 = drawn_line
|
||||
pygame.draw.line(self.screen, (255, 255, 255), (int(x1), int(y1)), (int(x2), int(y2)), 2)
|
||||
|
||||
self._print_status()
|
||||
|
||||
pygame.display.flip()
|
||||
self.clock.tick(60)
|
||||
self.clock.tick(10)
|
||||
Reference in New Issue
Block a user