fix: stop the arrow shaft overlapping the arrowhead#62
Merged
Conversation
insetEndpoints pulls curve endpoints back along their tangents by an arrowhead's base depth (headBaseInset = size * cos(spread)), scaling both insets down on tiny chords so endpoints never cross. buildElbowPath gains per-leg trims computed after the corners, so the mid-rail stays put and a trim can never invert a short final leg. Groundwork for #59.
When a head is drawn, the curve route feeds inset endpoints to routing and path build (so avoid detection matches the rendered shaft) and the elbow route trims its first/last leg. Heads stay anchored at the true socket points, so tips still touch the target edge. Draw-on ordering unchanged.
Math.min for the clamp scale, hoisted hasStartHead/hasEndHead so the shaft inset and head drawing can't desync, and one shared pathDs test helper. Behavior unchanged; suite stays green.
This was referenced Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Arrows with heads used to draw the shaft all the way into the arrowhead's tip, so the incoming line visibly crossed the head's V (plus rough.js wobble overshooting past it). The shaft now stops cleanly at the head's base — the tip still touches the target edge, and the junction reads as one drawn stroke.
The two routes get there differently, because they fail differently:
headSize * cos(π/7), the same spread constantarrowHeadPathuses). Obstacle-avoidance detection runs against the inset endpoints, so routing and rendering agree on the actual shaft. Tiny arrows scale both insets down so the endpoints can never cross.Arrowheads stay anchored at the true socket points, and the draw-on animation ordering is unchanged — heads still draw after the (now slightly shorter) line.
Plan:
docs/plans/2026-07-06-001-fix-shaft-head-overlap-plan.md. 19 new tests (geometry insets/trims/clamps and render-level assertions per head mode and route).Validation
vitest run— 169/169 green (15 files),tsc --noEmitand eslint clean, prettier check clean. Render behavior asserted via deterministic seeded rough.jsdstrings under jsdom; no live browser pass was run this session (dev-server use is disabled by user preference).Residual Review Findings
From the multi-agent code review (correctness, testing, maintainability, project-standards, adversarial + validators; verdict: ready with fixes — formatting fix applied on-branch):
test/scroll-arrow.test.ts—head: 'start'alone is never exercised at the render level (only'end'/'both'); filed as test: head:'start' alone is never exercised at the render level #61src/geometry.ts:249— elbow +head: 'both'on an arrow smaller than both trims collapses the shaft to a zero-length path (heads still render at their sockets); accepted degradation for arrows smaller than their own arrowheadssrc/geometry.ts:419— the chord-length clamp also throttles insets that run perpendicular to the chord (same-side-socket U-loops with short chords), partially re-admitting the old overlap in that narrow configurationRelated
Related: #59, #60