From 0a0b8b19dc59c82963b43c719b2fb2e139cb54f2 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sun, 16 Aug 2026 13:50:49 +0200 Subject: [PATCH] working lib --- examples/zickzack/index.html | 2 +- examples/zickzack/sketch.js | 14 ++++++-------- lib/WallPlotter.js | 13 ++++++------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/examples/zickzack/index.html b/examples/zickzack/index.html index a6f5a38..5b66771 100644 --- a/examples/zickzack/index.html +++ b/examples/zickzack/index.html @@ -44,7 +44,7 @@ } - + diff --git a/examples/zickzack/sketch.js b/examples/zickzack/sketch.js index 3dfc2b9..31f857a 100644 --- a/examples/zickzack/sketch.js +++ b/examples/zickzack/sketch.js @@ -1,6 +1,6 @@ let wp; -let area = 400; +let area = 120; function setup() { const canvas = createCanvas(windowWidth, windowHeight); @@ -42,15 +42,13 @@ async function drawArt(testOnly) { wp.move(-area, -area); //wp.wait(1000 * 10); - let step = area / 4.001; + let step = area / 2; - 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); + for (let y = -area; y <= area; y+=step){ + for (let x = -area; x <= area; x+=step){ + wp.move(x+step, y); wp.draw(x, y+step); - //} - } + } } await wp.runPath(testOnly); diff --git a/lib/WallPlotter.js b/lib/WallPlotter.js index 09d97c3..f894726 100644 --- a/lib/WallPlotter.js +++ b/lib/WallPlotter.js @@ -929,15 +929,14 @@ class WallPlotter { line(tl.x, 0, br.x, 0); line(0, tl.y, 0, br.y); - // Size labels in cm along bottom and right edges + // Size labels in cm + screen pixels along bottom and right edges const widthCm = (bounds.xMax - bounds.xMin) / 10; const heightCm = (bounds.yMax - bounds.yMin) / 10; - const widthLabel = Number.isInteger(widthCm) - ? `${widthCm} cm` - : `${widthCm.toFixed(1)} cm`; - const heightLabel = Number.isInteger(heightCm) - ? `${heightCm} cm` - : `${heightCm.toFixed(1)} cm`; + const widthPx = Math.round(Math.abs(w)); + const heightPx = Math.round(Math.abs(h)); + const fmtCm = (cm) => (Number.isInteger(cm) ? `${cm}` : cm.toFixed(1)); + const widthLabel = `${fmtCm(widthCm)} cm · ${widthPx} px`; + const heightLabel = `${fmtCm(heightCm)} cm · ${heightPx} px`; noStroke(); fill(bounds.preview ? 140 : 160); textFont('monospace', 12);