ok fix?
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Wall Plotter — zigzag</title>
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
background: #1c1c20;
|
||||
color: #ddd;
|
||||
font-family: system-ui, sans-serif;
|
||||
}
|
||||
h1 {
|
||||
position: absolute;
|
||||
top: 0.6rem;
|
||||
right: 0.75rem;
|
||||
z-index: 20;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
opacity: 0.85;
|
||||
pointer-events: none;
|
||||
text-align: right;
|
||||
}
|
||||
#sketch-host {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
}
|
||||
#sketch-host canvas {
|
||||
display: block;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
}
|
||||
</style>
|
||||
<script src="https://cdn.jsdelivr.net/npm/p5@1.11.3/lib/p5.min.js"></script>
|
||||
<script src="../../lib/WallPlotter.js?v=2.2.5"></script>
|
||||
<script src="sketch.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Wall Plotter — zigzag</h1>
|
||||
<main id="sketch-host"></main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,109 @@
|
||||
let wp;
|
||||
|
||||
let area = 320;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -42,7 +42,7 @@
|
||||
}
|
||||
</style>
|
||||
<script src="https://cdn.jsdelivr.net/npm/p5@1.11.3/lib/p5.min.js"></script>
|
||||
<script src="../../lib/WallPlotter.js?v=2.0.2"></script>
|
||||
<script src="../../lib/WallPlotter.js?v=2.2.5"></script>
|
||||
<script src="sketch.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user