Skip to content

feat: smart elbow arrows — perpendicular routing, rounded corners, style filters - #113

Open
Amark19 wants to merge 4 commits into
masterfrom
fix/elbow-smart-and-filters
Open

feat: smart elbow arrows — perpendicular routing, rounded corners, style filters#113
Amark19 wants to merge 4 commits into
masterfrom
fix/elbow-smart-and-filters

Conversation

@Amark19

@Amark19 Amark19 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Brings elbow arrows up to eraser.io/Excalidraw quality.

What changed

  • Smart routing. A bound elbow now records each end's exit direction (the outward normal of the shape edge it attaches to) and routes with perpendicular exits — stubbing out square from each edge, then connecting the stubs with a clean right-angled path — instead of cutting diagonally to a midpoint. Free-drawn elbows and live endpoint drags keep the simple mid-bend.
  • Rounded corners on every bend (short quadratic fillet + round joins/caps), matching the eraser/Excalidraw look. Route endpoints stay exact, so binding/hit-testing are unchanged.
  • Style filters now apply to elbow arrows. The panel only styled a straight line connector; it now styles the elbow's polyline too (width/style/colour + head recolour).

Verified in-browser

  • Elbow between two offset boxes: exits the source's right edge, steps, enters the target's left edge — perpendicular, rounded, clean.
  • Re-routes correctly on shape move (recomputes exit directions).
  • Bold + dashed + red applied to an elbow: sw 3→6, dash null→[24,18], stroke→red, head recoloured.
  • 89 unit tests pass (routing + rounded-corner + filter guards), ESLint + prettier clean.

Follow-up (not in this PR)

Obstacle-aware routing (paths that go around intervening shapes) and a curved arrow type / midpoint bend handles remain as larger, separate work.

🤖 Generated with Claude Code

Two elbow-arrow gaps vs eraser.io/Excalidraw:
- Style filters (width/style/colour) never applied to an elbow arrow. The panel's
  applyToActive only styled a `line` connector, skipping the elbow's `polyline` —
  so changing width/dash/colour did nothing. Now it styles both connector types.
- The elbow connector had sharp corners. It now renders with rounded corners
  (a short quadratic fillet at each bend, capped to the leg length) plus round
  line joins/caps, matching the eraser/Excalidraw look. The route's first/last
  points stay exact, so endpoints/binding/hit-testing are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 23, 2026

Copy link
Copy Markdown

Deploying whiteboard with  Cloudflare Pages  Cloudflare Pages

Latest commit: 178d82d
Status: ✅  Deploy successful!
Preview URL: https://6c3b0c85.whiteboard-988.pages.dev
Branch Preview URL: https://fix-elbow-smart-and-filters.whiteboard-988.pages.dev

View logs

Elbow arrows routed as a plain dominant-axis mid-bend that ignored which side of
each shape the endpoint sat on, so they cut diagonally toward a midpoint instead
of leaving the shape square-on. Now a bound elbow records each end's exit
direction (the outward edge normal, via binding's rerouteArrow) and the router
stubs out perpendicular to each edge, then connects the stubs with a clean
right-angled path (facing/perpendicular/opposed cases handled, collinear points
collapsed). Free-drawn elbows and live endpoint drags still use the plain
mid-bend. Combined with the rounded corners this matches the eraser.io/Excalidraw
elbow look.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Amark19
Amark19 force-pushed the fix/elbow-smart-and-filters branch from 377bfff to c988a6c Compare August 23, 2026 19:16
@Amark19 Amark19 changed the title fix: elbow arrows take style filters + get rounded corners feat: smart elbow arrows — perpendicular routing, rounded corners, style filters Aug 23, 2026
Amark19 and others added 2 commits August 24, 2026 11:50
A bound elbow froze its exit side to wherever it was first dropped, so moving a
shape to the opposite side forced an ugly wrap-around (the arrow looped out and
the tip could land off-canvas). Elbow re-routing now chooses each end's exit
side dynamically from the shapes' relative positions — attaching at the midpoint
of the edge that FACES the other end and exiting perpendicular — like
eraser.io/Excalidraw. Straight arrows still keep their dropped attach point.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…jog)

Elbow arrows now route with the shapes themselves as obstacles (grid + A*):
- an arrow between distant nodes goes AROUND intervening boxes instead of
  cutting through them;
- treating the arrow's own two endpoints as obstacles means it can no longer
  coil back inside them when shapes are dragged close/overlapping;
- nearly-aligned facing ports snap to a straight run, killing the tiny jog.

Pathfinding runs only over shapes near the arrow (kept cheap) and falls back to
the built-in perpendicular mid-bend when it can't connect the ports. New
utils/orthRoute.js owns the router; binding feeds it the obstacle set and a
pre-computed scene route flows through setArrowEndpoints -> applyEndpointsLocal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant