49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
from Gcode_generator import Gcode
|
|
from Gcode_generator import Machine
|
|
|
|
from HersheyFonts import HersheyFonts
|
|
import matplotlib.pyplot as plt
|
|
|
|
machine_type = Machine.THREEAXIS
|
|
|
|
# Create an instance of the Gcode class
|
|
gcode = Gcode(
|
|
file="test_gcode", # Output file name (no .gcode extension)
|
|
mm_per_px=0.1, # Conversion factor: mm per pixel
|
|
speed=1000, # Speed in mm/min
|
|
machine=machine_type,
|
|
max_s=255, # Laser power (only for LASER machines)
|
|
safe_z= 5,
|
|
work_z= 0
|
|
)
|
|
|
|
|
|
thefont = HersheyFonts()
|
|
thefont.load_default_font()
|
|
thefont.normalize_rendering(100)
|
|
|
|
text_lines = thefont.lines_for_text('Wallter is a wall plotter')
|
|
|
|
# print(next(text_lines)[0])
|
|
# first_point = next(text_lines)[0]
|
|
# gcode.go_to(first_point[0], first_point[1])
|
|
|
|
last_p2 = (0,0)
|
|
for (x1, y1), (x2, y2) in text_lines:
|
|
if((x1, y1) == last_p2):
|
|
gcode.write_to(x2 ,y2)
|
|
else:
|
|
gcode.draw_line(x1, y1, x2, y2)
|
|
|
|
last_p2 = (x2,y2)
|
|
|
|
|
|
|
|
# Draw a line from (10, 20) to (30, 40)
|
|
# gcode.draw_line(10, 20, 30, 40)
|
|
|
|
|
|
# Finish the G-code file
|
|
gcode.end_gcode()
|
|
|
|
print("G-code file generated: test_gcode.gcode") |