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(react): preserve seamless solid tone regions
Rudy Celekli63bb7749fd5e
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex bf7b18d..00a8593 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -57,6 +57,11 @@ jobs:node examples/raptor-engine/build.mjsnode examples/raptor-engine/build.mjs --light+ - name: React seamless solid regressions+ run: |+ npm install --prefix "$RUNNER_TEMP/anatomy-react-tests" --no-package-lock --no-save [email protected] [email protected] [email protected]+ NODE_PATH="$RUNNER_TEMP/anatomy-react-tests/node_modules" node --test scripts/react-solid-seamless.test.mjs+- name: Committed pages are unchangedrun: |git status --shortdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8152ae2..bd714af 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+- React `Solid` honors the existing `paths.seamless` marker so smooth tone regions receive the same seam treatment as the plain SVG renderer.+- `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/react/draw.tsx b/kit/react/draw.tsxindex 235f5a5..dcea322 100644--- a/kit/react/draw.tsx+++ b/kit/react/draw.tsx@@ -16,7 +16,7 @@ interface SolidProps {export function Solid({ paths, tone = "hi", crease = "faint", halo = false, lit = false, flat = false, className, inner, children }: SolidProps) {return (- <g className={className ? `iso-solid ${className}` : "iso-solid"} data-lit={lit ? "" : undefined}>+ <g className={className ? `iso-solid ${className}` : "iso-solid"} data-lit={lit ? "" : undefined} data-seamless={paths.seamless ? "" : undefined}>{halo ? <path className="iso-halo" d={paths.fill} /> : null}<path className="iso-fill" d={paths.fill} />{flat ? null : paths.shades.map((d, shade) => (d ? <path key={shade} className="iso-shade" data-shade={shade} d={d} /> : null))}diff --git a/scripts/react-solid-seamless.test.mjs b/scripts/react-solid-seamless.test.mjsnew file mode 100644index 0000000..b99d16e--- /dev/null+++ b/scripts/react-solid-seamless.test.mjs@@ -0,0 +1,47 @@+import assert from "node:assert/strict";+import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { createRequire } from "node:module";+import { tmpdir } from "node:os";+import { dirname, join, resolve } from "node:path";+import test from "node:test";+import * as G from "../kit/lathe.mjs";+const require = createRequire(import.meta.url);+const ts = require("typescript");+const React = require("react");+const { renderToStaticMarkup } = require("react-dom/server");+const directory = mkdtempSync(join(tmpdir(), "anatomy-react-solid-"));+try {+ for (const file of ["kit/iso-kit.ts", "kit/react/live.tsx", "kit/react/draw.tsx"]) {+ const output = join(directory, file.replace(/\.tsx?$/, ".js"));+ mkdirSync(dirname(output), { recursive: true });+ const result = ts.transpileModule(readFileSync(resolve(file), "utf8"), { fileName: file, compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022, jsx: ts.JsxEmit.React } });+ writeFileSync(output, result.outputText);+ }+ const { Solid } = require(join(directory, "kit/react/draw.js"));+ const P = { origin: [0, 0], scale: 1, azimuth: 45, elevation: 30 };+ for (const lit of [false, true]) test(`actual React renderer preserves seamless sphere tone regions with lit=${lit}`, () => {+ const paths = G.sphereOf([0, 0, 0], 4, P);+ assert.equal(paths.seamless, true);+ assert.ok(paths.shades.some(Boolean));+ const html = renderToStaticMarkup(React.createElement("svg", null, React.createElement(Solid, { paths, lit })));+ assert.match(html, /data-seamless=""/);+ assert.equal(/data-lit=""/.test(html), lit);+ assert.match(html, /class="iso-shade"/);+ });+ test("actual React renderer preserves ordinary hard solids", () => {+ const paths = G.prismOf(G.frameAlong([0, 0, 0], [0, 0, 1]), [[-1, -1], [1, -1], [1, 1], [-1, 1]], 0, 2, P);+ assert.equal(Boolean(paths.seamless), false);+ const html = renderToStaticMarkup(React.createElement(Solid, { paths }));+ assert.doesNotMatch(html, /data-seamless/);+ assert.match(html, /class="iso-line iso-edge"/);+ });+ test("actual React renderer preserves seamless opt-out and child ordering", () => {+ const paths = { ...G.sphereOf([0, 0, 0], 4, P), seamless: false };+ const html = renderToStaticMarkup(React.createElement(Solid, { paths, inner: React.createElement("circle", { id: "inner" }) }, React.createElement("circle", { id: "child" })));+ assert.doesNotMatch(html, /data-seamless/);+ assert.ok(html.indexOf('id="inner"') < html.indexOf('class="iso-line iso-edge"'));+ assert.ok(html.indexOf('id="child"') > html.indexOf('class="iso-line iso-edge"'));+ });+} finally {+ rmSync(directory, { recursive: true, force: true });+}diff --git a/tests/fixtures/react-solid-dark.png b/tests/fixtures/react-solid-dark.pngnew file mode 100644index 0000000..5c37a48Binary files /dev/null and b/tests/fixtures/react-solid-dark.png differdiff --git a/tests/fixtures/react-solid-light.png b/tests/fixtures/react-solid-light.pngnew file mode 100644index 0000000..d83c25eBinary files /dev/null and b/tests/fixtures/react-solid-light.png differ