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(audit): restore closed-path subpath origins
Rudy Celekli06eef7dea066
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex bf7b18d..9218a47 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -25,6 +25,9 @@ jobs:with:node-version: 22+ - name: Closed path audit regressions+ run: node --test scripts/audit-path-origin.test.mjs+- name: Dial indicatorrun: |node examples/dial-indicator/build.mjsdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8152ae2..7597a45 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+- Fixed-part and coverage bounds restore a closed SVG subpath origin before relative moves.+- `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/kit/audit.mjs b/kit/audit.mjsindex f52d06c..9bfc9d3 100644--- a/kit/audit.mjs+++ b/kit/audit.mjs@@ -1386,6 +1386,8 @@ function pointsOfShape(tag, attrs) {const out = [];let x = 0;let y = 0;+ let sx = 0;+ let sy = 0;for (const [, command, args] of d.matchAll(/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g)) {const v = (args.match(NUMBER) ?? []).map(Number);const rel = command === command.toLowerCase();@@ -1398,11 +1400,18 @@ function pointsOfShape(tag, attrs) {if (C === "H") for (const value of v) [x] = take([value + (rel ? x : 0), y]);else if (C === "V") for (const value of v) [, y] = take([x, value + (rel ? y : 0)]);else if (C === "A") for (let i = 0; i + 6 < v.length; i += 7) [x, y] = take([v[i + 5] + (rel ? x : 0), v[i + 6] + (rel ? y : 0)]);- else if (C !== "Z") {+ else if (C === "Z") {+ x = sx;+ y = sy;+ } else {const width = C === "C" ? 6 : C === "S" || C === "Q" ? 4 : 2;for (let i = 0; i + 1 < v.length; i += width) {for (let j = 0; j < width; j += 2) out.push(pair(i + j));[x, y] = pair(i + width - 2);+ if (C === "M" && i === 0) {+ sx = x;+ sy = y;+ }}}}diff --git a/scripts/audit-path-origin.test.mjs b/scripts/audit-path-origin.test.mjsnew file mode 100644index 0000000..aec7169--- /dev/null+++ b/scripts/audit-path-origin.test.mjs@@ -0,0 +1,26 @@+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";+import { markupBox } from "../kit/audit.mjs";++const execute = promisify(execFile);+for (const [name, markup] of [+ ["relative move after closing a subpath", '<path d="M10 10L20 10L20 20Z m5 0l2 0"/>'],+ ["transformed relative move after closing a subpath", '<g transform="translate(5 3)"><path d="M10 10L20 10L20 20Z m5 0l2 0"/></g>'],+ ["absolute move after closing a subpath", '<path d="M10 10L20 10L20 20Z M15 10L17 10"/>'],+ ["open relative segments", '<path d="M10 10l10 0l0 10m5 0l2 0"/>'],+]) test(`audit bounds match actual native SVG for ${name}`, async () => {+ const directory = await mkdtemp(join(tmpdir(), "anatomy-audit-path-origin-"));+ try {+ const page = join(directory, "figure.html");+ await writeFile(page, `<!doctype html><div class="iso-plate"><svg width="100" height="100" viewBox="0 0 100 100">${markup}</svg></div>`);+ const actions = JSON.stringify([["eval", "(()=>{const b=document.querySelector('svg').getBBox();return [b.x,b.y,b.x+b.width,b.y+b.height]})()"]]);+ const result = await execute(process.execPath, ["scripts/drive.mjs", page, actions], { timeout: 30000 });+ const native = JSON.parse(result.stdout.match(/eval: (.*)/)[1]);+ assert.deepEqual(markupBox(markup), native);+ } finally { await rm(directory, { recursive: true, force: true }); }+});