Files
wallter/plotter-app/text_to_gcode.py

32 lines
867 B
Python

from Gcode_generator import Gcode
from Gcode_generator import Machine
from HersheyFonts import HersheyFonts
import matplotlib.pyplot as plt
machine_type = Machine.LASER
# 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)
)
thefont = HersheyFonts()
thefont.load_default_font()
thefont.normalize_rendering(100)
for (x1, y1), (x2, y2) in thefont.lines_for_text('Wallter is a wall plotter'):
gcode.draw_line(x1, y1 ,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: example.gcode")