Skip to content

Add offsetPath: move a floor polyline sideways with mitred corners - #137

Open
dbritto-dev wants to merge 1 commit into
wheresryan22:mainfrom
dbritto-dev:offset-path
Open

dbritto-dev wants to merge 1 commit into
wheresryan22:mainfrom
dbritto-dev:offset-path

Conversation

@dbritto-dev

@dbritto-dev dbritto-dev commented Oct 20, 2026 •

Copy link
Copy Markdown

What this changes

Adds offsetPath(points, by, limit = 4) to the kit: a floor polyline moved sideways by by, point for point.

  • A positive by moves a path that runs along +x toward +y.
  • Interior corners are mitred so both adjacent legs stay exactly by away; a mitre never reaches past limit × by from its corner (like SVG's stroke-miterlimit).
  • Repeated points take the direction of their nearest real segment, so they move with their neighbours; a single point, or a path of one repeated point, stays put.

It is in kit/iso-kit.ts and kit/iso-kit.mjs (the transpiled output, unchanged elsewhere), listed in references/kit.md under "Solids" next to insetPlan, and covered by scripts/offset-path.test.mjs: straight paths both ways, square corners inside and outside, the exact by distance from both segments along a curve, the mitre limit on a hairpin, repeated points, and the TypeScript twin.

Why

Two-edged things follow one centreline: both rails of a track, the edges of a belt, a lane, a road, a pair of parallel cables. The kit can fillet, resample, cut and walk a path, but not offset one, so a figure had to compute normals and corner joins itself. A railway-junction figure needed it for its bed, both rails and its sleepers.

Checks

  • Every example rebuilds, and git status --short shows only the changes I meant. The pages that inline the kit (dial indicator, desk computer, arcade cabinet, ripple tank, push button, both themes) gain the function and nothing else.
  • No comments in code.
  • Kit changes are opt-in: one new export, no existing function changes.
  • I built and looked at both themes (demo below).
  • Audit: node examples/raptor-engine/build.mjs --light --audit ends audit passed on this branch (80 tubes, 267 solids, 478 items, 1,119 depth states). This PR changes no pipe, cable or round part.
  • node scripts/lines.mjs prints line ends: 0 on all ten pages this PR changes: dial indicator, desk computer, arcade cabinet, ripple tank and push button, light and dark.
  • Shaders: the ripple tank is the only shader page that changes (it inlines the kit; no shader source changed). Its reduced-motion stills are pixel-identical to main (0 differing pixels), light and dark, with WebGL and with --no-webgl.
  • 3D: a full node examples/turning-dial/build.mjs --light --audit on this branch reports the same 4 problems as main, where the full report is every line 0 except crowding: 4 (cable.green end × hand.f3.p1 at 165°, cable.blue end × hand.f3.p1 at 200°, cable.red end × hand.f1.p1 at 210°, cable.green end × hand.piston.rod at 285°), so they come from the turning-dial example, not this PR. scripts/turn-check.mjs examples/turning-dial/build.mjs --fidelity passes, and the turning-dial pages rebuild byte-identical to main.
  • Every number in the docs is true.
  • A line under Unreleased in CHANGELOG.md.

node --test scripts/*.test.mjs: 296 of 296 pass.

This and the sideOutline PR (#136) each add a CHANGELOG.md line in the same spot, so whichever merges second needs a one-line rebase.

Screenshots

A demo plate (not committed): the bed edges (±8), both rails (±4) and the sleepers all come from one S-curve centreline through offsetPath.

Light Dark
light dark
light 4× dark 4×

🤖 Generated with Claude Code

https://claude.ai/code/session_01S5z2gCvevbrGU3fXgpGDmP

A track, a belt or a lane has two edges that follow one centreline. The kit
can fillet, resample and walk a path, but not offset one, so each figure
had to work out its own normals and corner joins.

offsetPath(points, by, limit) returns the path moved sideways by `by`,
point for point. A positive `by` moves a path that runs along +x toward
+y. Corners are mitred so both legs stay `by` away, a mitre never reaches
past `limit` x `by` from its corner, and repeated points move with their
neighbours.

It is a new export; nothing existing changes. The pages that inline the
kit (dial indicator, desk computer, arcade cabinet, ripple tank, push
button) gain the function and nothing else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5z2gCvevbrGU3fXgpGDmP
Copilot AI balanced review requested due to automatic review settings October 20, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants