UNPKG

@thi.ng/axidraw

Version:

Minimal AxiDraw plotter/drawing machine controller for Node.js

19 lines (18 loc) 510 B
import { DOWN, MOVE, PEN, UP } from "./commands.js"; function* polyline(pts, opts = {}) { if (!pts.length) return; const { speed = 1, onlyGeo = false, delayDown, delayUp, down } = opts; if (onlyGeo) { for (let p of pts) yield MOVE(p, speed); return; } yield MOVE(pts[0]); if (down !== void 0) yield PEN(down); yield DOWN(delayDown); for (let i = 1, n = pts.length; i < n; i++) yield MOVE(pts[i], speed); yield UP(delayUp); if (down !== void 0) yield PEN(); } export { polyline };