supports-thickness slider — relative shaft width for supports edges

A LINEAR 0–1 multiplier of Edge width (default 0.5, dead-center at step
0.1 — 11 stops like the ladder rows but ratio-valued), grayed out by the
supports-edges toggle (the Dilation dependency pattern). Renderer splits
supports shafts into their own Path2D and strokes a second pass at
edgeWidth × supportsWidth; arrowheads stay full-geometry in the one shared
path (owner pick: shaft only). A true 0-width stroke is undefined on
canvas — the 0 end floors to a 0.5px on-screen hairline; hiding remains
the toggle's job. Sanitizer: real numbers clamp to [0,1], everything else
resets to 0.5; clamps pinned in render-settings.test.
This commit is contained in:
amosblomqvist
2026-09-29 03:00:57 +03:00
parent 6543d4f886
commit f5a9ed59c7
4 changed files with 69 additions and 7 deletions
+14
View File
@@ -119,6 +119,7 @@ describe("sanitizeRenderSettings", () => {
labelZoom: 2,
labelSize: 4,
showSupports: false,
supportsWidth: 0.3,
clusterLabels: false,
clusterLabelSize: 20,
regions: DEFAULT_REGION_TUNING,
@@ -137,6 +138,19 @@ describe("sanitizeRenderSettings", () => {
assert.equal(sanitizeRenderSettings({ showSupports: 0 }).showSupports, true);
});
test("supportsWidth (2026-09-29): linear 0–1 ratio of edgeWidth, default 0.5", () => {
// The supports shaft-thickness multiplier: LINEAR (not a ladder —
// it's a ratio), real numbers clamp to [0, 1], anything else resets
// to the default. The 0 end floors to a hairline in the renderer.
assert.equal(sanitizeRenderSettings({}).supportsWidth, 0.5);
assert.equal(sanitizeRenderSettings({ supportsWidth: 0 }).supportsWidth, 0);
assert.equal(sanitizeRenderSettings({ supportsWidth: 1 }).supportsWidth, 1);
assert.equal(sanitizeRenderSettings({ supportsWidth: 0.37 }).supportsWidth, 0.37);
assert.equal(sanitizeRenderSettings({ supportsWidth: 1.7 }).supportsWidth, 1);
assert.equal(sanitizeRenderSettings({ supportsWidth: -0.3 }).supportsWidth, 0);
assert.equal(sanitizeRenderSettings({ supportsWidth: "thick" }).supportsWidth, 0.5);
});
test("the pre-2026-09-13 stored shape (flat, no regions/physics) still loads", () => {
// data/render-settings.json on disk predates the nested sections —
// those loads must get defaults, not crash, not shift anything.