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

57 lines
1.1 KiB
JavaScript

let wp;
let area = 120;
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(10000, 10000);
wp.setTimingMultiplier(1); // tune if machine is slower than speed estimate, the higher the slower
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) {
wp.startPath();
wp.move(-area, -area);
//wp.wait(1000 * 10);
let step = area / 6;
for (let y = -area; y <= area; y+=step){
for (let x = -area; x <= area; x+=step){
//if(random(1) < 0.8){
wp.draw(x, y);
wp.draw(x+(random(1)<0.9), y+random(step*1.5));
//}
}
}
await wp.runPath(testOnly);
}