tutorial
This commit is contained in:
@@ -1,109 +0,0 @@
|
||||
let wp;
|
||||
|
||||
let area = 100;
|
||||
|
||||
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 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 / 40;
|
||||
|
||||
let points = [];
|
||||
let last_points = [];
|
||||
let row = -1;
|
||||
|
||||
for (let y = -area; y <= area; y+=step){
|
||||
|
||||
// clear points
|
||||
if(points.length>0){
|
||||
last_points = deepCopy(points);
|
||||
points = [];
|
||||
}
|
||||
|
||||
let px = -area;
|
||||
let py = y+random(10)
|
||||
if (row==1){
|
||||
py = last_points[0].y;
|
||||
}
|
||||
|
||||
|
||||
wp.move(px, py);
|
||||
points.push(createVector(px,py));
|
||||
|
||||
let index = 1;
|
||||
for (let x = -area+step; x <= area; x+=step){
|
||||
px = x;
|
||||
py = y+random(step);
|
||||
|
||||
if (row==1 && index%2==0){
|
||||
py = last_points[index].y
|
||||
}
|
||||
|
||||
if (row==1 && index%2!=0){
|
||||
py = last_points[index-1].y+random(step*3);
|
||||
}
|
||||
|
||||
if (last_points.length>0 && row==-1 && index%2!=0){
|
||||
py = last_points[index].y
|
||||
}
|
||||
|
||||
if (last_points.length>0 && row==-1 && index%2==0){
|
||||
py = last_points[index-1].y+random(step*1);
|
||||
}
|
||||
|
||||
wp.draw(px, py);
|
||||
points.push(createVector(px,py));
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
row = row*-1;
|
||||
|
||||
}
|
||||
await wp.runPath(testOnly);
|
||||
}
|
||||
|
||||
|
||||
function deepCopy(copy_array){
|
||||
let new_array = []
|
||||
for(let i=0; i<copy_array.length; i++){
|
||||
new_array.push(copy_array[i]);
|
||||
}
|
||||
return new_array;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Wall Plotter — zigzag</title>
|
||||
<title>Wall Plotter — rectangle</title>
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
@@ -46,7 +46,7 @@
|
||||
<script src="sketch.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Wall Plotter — zigzag</h1>
|
||||
<h1>Wall Plotter — rectangle</h1>
|
||||
<main id="sketch-host"></main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,46 @@
|
||||
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);
|
||||
}
|
||||
@@ -28,14 +28,14 @@ function windowResized() {
|
||||
}
|
||||
|
||||
async function plot() {
|
||||
await drawArt(false);
|
||||
await drawPlot(false);
|
||||
}
|
||||
|
||||
async function test() {
|
||||
await drawArt(true);
|
||||
await drawPlot(true);
|
||||
}
|
||||
|
||||
async function drawArt(testOnly) {
|
||||
async function drawPlot(testOnly) {
|
||||
wp.startPath();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user