Add WallPlotter p5 library with zigzag example.
Standalone package for Marlin polargraph control over Web Serial, including API docs and a runnable zigzag sketch. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
let wp;
|
||||
|
||||
let area = 400;
|
||||
|
||||
function setup() {
|
||||
const canvas = createCanvas(windowWidth, windowHeight);
|
||||
canvas.parent('sketch-host');
|
||||
|
||||
wp = new WallPlotter();
|
||||
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 drawArt(false);
|
||||
}
|
||||
|
||||
async function test() {
|
||||
await drawArt(true);
|
||||
}
|
||||
|
||||
async function drawArt(testOnly) {
|
||||
wp.startPath();
|
||||
|
||||
|
||||
wp.move(-area, -area);
|
||||
wp.wait(1000 * 10);
|
||||
|
||||
let step = area / 20;
|
||||
|
||||
for (let y = -area; y < area; y+=step){
|
||||
for (let x = -area; x < area; x+=step){
|
||||
if(random(1) < 0.8){
|
||||
wp.move(x, y);
|
||||
wp.draw(x, y+step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await wp.runPath(testOnly);
|
||||
}
|
||||
Reference in New Issue
Block a user