An agent skill for creating detailed, interactive isometric illustrations of real-world machines and complex systems. Generates polished SVGs with optional WebGL shaders and 3D effects.
fix(lines): respect Bezier continuation control families
Rudy Celekliff03e61840ef
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex bf7b18d..42ea265 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -25,6 +25,9 @@ jobs:with:node-version: 22+ - name: Bezier continuation regressions+ run: node --test scripts/lines-bezier.test.mjs+- name: Dial indicatorrun: |node examples/dial-indicator/build.mjsdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8152ae2..5bc5386 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,8 @@ All notable changes to Anatomy are recorded here. The format follows [Keep a Cha### Fixed+- The line verifier reflects smooth Bezier controls only after the matching curve family.+- `examples/test-rig/` drew its glass button dark in the light theme. `stretch.css` now has light values for its own colours.### Changeddiff --git a/scripts/line-ends.mjs b/scripts/line-ends.mjsindex 4f8a772..960bcaa 100644--- a/scripts/line-ends.mjs+++ b/scripts/line-ends.mjs@@ -45,7 +45,7 @@ function lineEnds({ select = null, tolerance = 1, root: rootSlack = 2, mark = 7,const u = 1 - t;push(u * u * u * x0 + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t * t * t * px, u * u * u * y0 + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t * t * t * py);}- control = [x2, y2];+ control = { kind: "cubic", point: [x2, y2] };};const quad = (x1, y1, px, py) => {const x0 = x;@@ -55,7 +55,7 @@ function lineEnds({ select = null, tolerance = 1, root: rootSlack = 2, mark = 7,const u = 1 - t;push(u * u * x0 + 2 * u * t * x1 + t * t * px, u * u * y0 + 2 * u * t * y1 + t * t * py);}- control = [x1, y1];+ control = { kind: "quadratic", point: [x1, y1] };};for (const [, command, args] of d.matchAll(/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g)) {const v = numbers(args);@@ -86,13 +86,13 @@ function lineEnds({ select = null, tolerance = 1, root: rootSlack = 2, mark = 7,else if (C === "C") for (let i = 0; i + 5 < v.length; i += 6) cubic(v[i] + ox(), v[i + 1] + oy(), v[i + 2] + ox(), v[i + 3] + oy(), v[i + 4] + ox(), v[i + 5] + oy());else if (C === "S")for (let i = 0; i + 3 < v.length; i += 4) {- const reflected = control ? [2 * x - control[0], 2 * y - control[1]] : [x, y];+ const reflected = control?.kind === "cubic" ? [2 * x - control.point[0], 2 * y - control.point[1]] : [x, y];cubic(reflected[0], reflected[1], v[i] + ox(), v[i + 1] + oy(), v[i + 2] + ox(), v[i + 3] + oy());}else if (C === "Q") for (let i = 0; i + 3 < v.length; i += 4) quad(v[i] + ox(), v[i + 1] + oy(), v[i + 2] + ox(), v[i + 3] + oy());else if (C === "T")for (let i = 0; i + 1 < v.length; i += 2) {- const reflected = control ? [2 * x - control[0], 2 * y - control[1]] : [x, y];+ const reflected = control?.kind === "quadratic" ? [2 * x - control.point[0], 2 * y - control.point[1]] : [x, y];quad(reflected[0], reflected[1], v[i] + ox(), v[i + 1] + oy());}else if (C === "A") for (let i = 0; i + 6 < v.length; i += 7) push(v[i + 5] + ox(), v[i + 6] + oy());diff --git a/scripts/lines-bezier.test.mjs b/scripts/lines-bezier.test.mjsnew file mode 100644index 0000000..55ff583--- /dev/null+++ b/scripts/lines-bezier.test.mjs@@ -0,0 +1,28 @@+import assert from "node:assert/strict";+import { execFile } from "node:child_process";+import { mkdtemp, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { promisify } from "node:util";+import test from "node:test";++const execute = promisify(execFile);+for (const [name, path, x, y] of [+ ["quadratic then smooth cubic", "M20 60 Q40 20 60 60 S80 100 100 60", 72.5, 75],+ ["cubic then smooth quadratic", "M20 60 C30 20 50 20 60 60 T100 60", 80, 60],+ ["matching cubic continuation", "M20 60 C30 20 50 20 60 60 S80 100 100 60", 76.25, 90],+ ["matching quadratic continuation", "M20 60 Q40 20 60 60 T100 60", 80, 80],+]) test(`native SVG ${name} roots a line on the actual curve`, async () => {+ const directory = await mkdtemp(join(tmpdir(), "anatomy-bezier-control-"));+ try {+ const file = join(directory, "figure.html");+ await writeFile(file, `<!doctype html><div class="iso-plate"><svg width="140" height="120" viewBox="0 0 140 120"><path id="curve" fill="none" stroke="black" d="${path}"/><path class="iso-line" data-free="start" fill="none" stroke="black" d="M${x} 10L${x} ${y}"/></svg></div>`);+ const actions = JSON.stringify([["eval", `document.querySelector('#curve').isPointInStroke(new DOMPoint(${x},${y}))`], ["lines"]]);+ let result;+ try { result = { code: 0, ...await execute(process.execPath, ["scripts/drive.mjs", file, actions], { timeout: 30000 }) }; }+ catch (error) { result = { code: error.code, stdout: error.stdout, stderr: error.stderr }; }+ assert.match(result.stdout, /eval: true/);+ assert.equal(result.code, 0);+ assert.match(result.stdout, /line ends: 0 of 1/);+ } finally { await rm(directory, { recursive: true, force: true }); }+});