This README was generated by Claude
Command shortcuts, command optimizations, and output preview
Put easyplot in a directory within your project
import easyplot.easyplot as ep
def main():
ep.init()
#ep plot commands go here
ep.end()python easyplot/cli.py <path to hpgl file> <--optimize | --preview>
NVM THIS ISN'T DONE
Coordinates are plotter units: 1 unit = 0.025 mm.
ep.BOUNDS = [10300, 7650] (page), ep.UNITS_PER_mm = 40, ep.UNITS_PER_INCH = 1016.
Speeds are cm/s; font height and kerning are mm.
The carriage is the set of pens physically loaded in the plotter: 8 slots, 0-indexed (vs HP-GL/1 1-indexing), empty slots hold the int 0. ep.init() optionally takes one and ep.switchPen(slot) selects from it.
import easyplot.easyplot as ep
Shapes leave the pen up. arc, circle, rect, square and text are filled per the current fill mode; polyline, line and regularPolygon are not.
ep.init(penCarriage: PenCarriage = ALL_BLACK, carriageIndex: int = 3, startX: int = 0, startY: int = 0)
ep.end(show: bool = True, outputPath: str = "output.txt") # optimize, write, preview
ep.debugPrint() # last 5 instructions
ep.switchPen(carriageIndex: int | None) # None = no-op
ep.setSpeed(cm_per_second: int)
ep.set(x: float, y: float) # absolute (PA)
ep.move(x: float, y: float) # relative (PR)
ep.penDown() / ep.penUp()
ep.getPos() -> list[int]
ep.line(x1: float, y1: float, x2: float, y2: float)
ep.point(x: float, y: float)
ep.polyline(points: list[tuple[float, float]])
ep.bezier(startx, starty, c1x, c1y, c2x, c2y, endx, endy, stepSize: float = 80)
ep.arc(x: float, y: float, r: float, rads: float, rot: float = 0, stepSize: float = 40)
ep.circle(x: float, y: float, r: float, stepSize: float = 40)
ep.rect(x: float, y: float, w: float, h: float) # x,y = lower-left
ep.square(x: float, y: float, s: float)
ep.regularPolygon(x: float, y: float, radius: float, sides: int, rotation: float = 0)
ep.setFillMode(mode: FILLMODE, penSlotFill: int = None, lineAngle: float = 0,
fillSpacing: float = 0.75, speed: int = 10)
ep.setFont(font: str = None, height_mm: float = 10.0, justification: JUSTIFY = JUSTIFY.LEFT,
kerning_mm: float = 0.0, outline: bool = True)
ep.text(s: str, x: float, y: float)
ep.getStringWidth(string: str) -> float
ep.getCharSize(char: str) -> float
ep.FILLMODE.NONE | LINE | CONTOUR # LINE = hatch at lineAngle, CONTOUR = inset rings
ep.JUSTIFY.LEFT | CENTER | RIGHT # applied about xfrom easyplot.optimize_verify_estimate import OVE
OVE(instructions: list[str], carriage: PenCarriage) -> list[str]Called by end(); run manually only on a raw instruction list.
import easyplot.pen_definition as pd
pd.PenDefinition(r: int, g: int, b: int, width_mm: float)
.color -> tuple[int, int, int] # preview only
.width_mm -> float
.pixel_width -> float # width_mm * 40, drives fill spacing
.DARKNESS = 0.9 # class attr, preview alpha
pd.PenCarriage(penArray: list[PenDefinition | int] = [0] * 8)
.slots -> list[PenDefinition | int]
.loadPen(slot: int, pen: PenDefinition) # 0-7, no-op if occupied
.getUsedSlots() -> list[int]
.getSlot(slot: int) -> PenDefinition | int # 0 if empty, None if out of range
pd.ALL_BLACK # MICRON_BLACK_05 in all 8 slotsPresets, MICRON_<COLOR>_<NIB> where nib is the Micron size (01 = 0.25 mm,
05 = 0.45, 08 = 0.50, 10 = 0.60):
LIGHT_COOL_GRAY and COOL_GRAY in 01/05/08/10, BLACK in 05/10, and
SEPIA/BLUE/GREEN/RED/PURPLE/ROSE/BROWN in 05.
from easyplot.plot_preview import preview
preview(instructions: list[str], carriage: PenCarriage)separate instrs into a python list first. Only supports one pair of coords per line rn :(
import easyplot.easyplot as ep
ep.init()
ep.setFillMode(ep.FILLMODE.LINE)
ep.setFont("Sofachrome Rg.otf", 14, ep.JUSTIFY.CENTER)
text = "warning: plotting"
ep.text(text, ep.BOUNDS[0]/2, ep.BOUNDS[1]/8*2)
text = "steals batches"
ep.text(text, ep.BOUNDS[0]/2, ep.BOUNDS[1]/8)
ep.end()