Files
p5-wallplotter/examples/rechteck/sketch.js
T
2026-09-05 13:39:34 +02:00

47 lines
976 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
let wp;
function setup() {
const canvas = createCanvas(windowWidth, windowHeight);
canvas.parent('sketch-host');
wp = new WallPlotter({
penUpGcode: 'M280 P0 S120',
penDownGcode: 'M280 P0 S30',
penUpDelayMs: 250,
penDownDelayMs: 150,
});
wp.setSpeed(3000, 1500);
wp.setTimingMultiplier(1);
wp.enableKeyInputs();
wp.enablePlotButtons();
}
function draw() {
background(28, 28, 32);
wp.showInfos();
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
async function plot() {
await drawPlot(false);
}
async function test() {
await drawPlot(true);
}
async function drawPlot(testOnly) {
const s = 200; // 400 × 400 mm around home
wp.startPath();
wp.move(-s, -s); // pen up to bottom-left
wp.draw(s, -s); // bottom edge
wp.draw(s, s); // right edge
wp.draw(-s, s); // top edge
wp.draw(-s, -s); // left edge, close the rectangle
wp.move(0, 0); // pen up back to home
await wp.runPath(testOnly);
}