Skip to content

FE-2427: Spread the arcs of a node along its sides and sharpen arc heads - #10712

Draft
kube wants to merge 2 commits into
mainfrom
cf/fe-2427-canvas-arc-routing
Draft

kube wants to merge 2 commits into
mainfrom
cf/fe-2427-canvas-arc-routing

Conversation

@kube

@kube kube commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Stored settings change
petrinaut:user-settings in localStorage takes an arcRouting object of six numbers.
Existing settings load unchanged and take the default routing values.
A build without this PR loads settings that have arcRouting and ignores it.

Summary

Before this PR, an arc met a node where the line between the two node centres crossed its outline. Arcs of a busy node shared points on the outline and lay on each other. Arrowheads had round corners and touched the node they pointed at.

Core routes the arcs of a node together. Each end takes a side of its node and a point on that side, at even distances in the order of where the arcs go, and turns towards the node at its other end. Arrowheads are sharp, lie in line with their arc and stop 4 units short of the node. Six routing values change under Settings > Labs > Arc routing while a net is on screen.

10712.mp4

Stored settings

petrinaut:user-settings in localStorage takes an arcRouting object that holds the six routing values. It is written whole, with the other settings.

Example and loading: settings load in both directions with no migration
   "showCompilationOutput": false,
+  "arcRouting": {
+    "spacing": 16,
+    "sidePreference": 0.5,
+    "lean": 0.5,
+    "fan": 0.5,
+    "maxTurn": 40,
+    "stagger": 1.5
+  },
   "disabledPluginIds": [],
  • Existing settings load unchanged

    arcRouting takes the six defaults and is written to storage on load.

  • A build without this PR ignores arcRouting

    Its other settings load. The object stays in storage through later writes.

  • A stored object with a missing or out-of-range value is made whole on load

    A missing value takes its default, and a value out of range the nearest one in range.

Links

Changes

Core: placeArcEnds and getArcLine route every arc of a net in the layout layer
  • Each arc end takes a side of its node

    With no preference an end takes the side that faces its other node.
    sidePreference widens the left side for an arc that arrives and the right side for one that leaves.

  • Ends of one side stand at even distances

    Their order follows where the arcs go, clockwise, so two arcs do not cross on their way out.
    A side too short for spacing shares its length evenly.

  • Each end turns towards its other node and fans out from the middle of its side

    lean and fan set the two amounts, and maxTurn caps their sum.
    Two neighbours of a side never turn towards each other.

  • Arc stops short of its node and ends straight

    arcTipGap is 4 units, measured square to the outline.
    arcLastStretch is 8.5 units, where the head lies.

  • Arcs that head the same way bend apart

    stagger turns the arc on the inside of a bend sooner than its neighbour, and bows the two arcs of a two-way pair apart.

  • A routing reuses the one before

    A node is placed again only when one of its ends changed.
    An arc that draws the same keeps its PlacedArc object, so the canvas keeps its curve during a drag.

  • Six values in one ArcRoutingSettings object, read on every call

    resolveArcRoutingSettings fills in a missing value and brings the rest into range.

Canvas: arc layer routes through the core, and heads are sharp
  • Arc layer places every arc with placeArcEnds

    A moved node counts the arcs of the nodes its arcs go to as moving too, because their ends shift with it.

  • Arrowhead is a sharp triangle 9 units long and 10.5 wide

    Its back is cut in by half a unit, where the line runs into it.
    An arc in a casing wears a head 13 units long and 16.5 wide.

  • Line of an arc stops inside its head with a round end

    The distance follows from the shape of the head, so no line shows beside it.

  • Connection preview aims at the centres of its nodes

    A dropped arc takes its point among the other arcs.

Settings: Labs gets an Arc routing group with a slider for each value
  • arcRouting user setting holds the six values

    Canvas reads it on every routing, so a slider moves the arcs while it is dragged.

  • Settings > Labs > Arc routing lists Spacing, Side preference, Lean, Fan, Maximum turn and Stagger

    Each row shows its value as text. Restore puts all six back to their defaults.

  • Up and Down arrows walk past a slider

    Left and Right change its value.

Guide figures: two interactive figures and a shared loader on the docs site
  • Arc routing guide has a side dial and a playground

    Both call the core routing. Playground has draggable nodes, the six sliders and a Reset button.

  • Shared lazyFigure loads a figure when it scrolls into view

    Token encoding playground loads through it too.

Known issues

  • Default routing values are not settled

    Labs sliders are there to tune them on real nets.

  • Connection preview and dropped arc differ

    An arc being drawn aims at node centres and moves to its own point when dropped.

  • User guide images do not show the routing

    Arc image in Drawing a Net predates it, and the Arc routing section of User Settings has no image.

Test coverage

Unit tests: routing rules in core, canvas arcs and heads, stored values and sliders
  • arc-routing.test.ts:

    Side, point and turn of every end, equal results with and without the routing before, and kept objects for arcs a move does not reach.

  • choose-side.test.ts, never-falling.test.ts, arc-line.test.ts, settings.test.ts, outline.test.ts:

    Reach of each side, the neighbour rule, curve with tip gap and stagger, value resolution, and outlines.

  • arc-shapes.test.ts, arc-geometry.test.ts, arc-head.test.ts, outline-connection-line.test.tsx:

    Canvas routing through the core, recomputing only the arcs a moved node changes, head shape, and the centre-aimed preview.

  • user-settings-provider.test.tsx, user-settings.test.tsx, setting-slider.test.tsx, arc-routing-rows.test.ts:

    Stored values made whole, slider changes and Restore in Labs, and keyboard walking past a slider.

  • side-ranges.test.ts:

    Ranges the side dial draws for each preference.

Browser checks: Storybook canvas and Labs sliders, figures on the built docs site
  • Storybook, supply chain example:

    Spacing at 40 px re-routes the arcs and is stored.
    Restore returns the same arc paths.
    Console stays free of errors.

  • Built docs site:

    Guide diagram renders.
    Side dial follows its slider and the arrow keys.
    Playground follows a dragged node, its sliders and Reset.

  • Stored settings across builds:

    Provider of the base commit and of this branch each rendered against settings the other one stored.

How to test

Canvas: arcs spread along node sides, sharp heads
  • Menu > Load example > Supply Chain With Disruption
  • Zoom in on a node with several arcs

    Expect each arc at its own point along a side, heads sharp and clear of the node

  • Drag that node past one of its neighbours

    Expect arcs to change sides and order as the node moves

  • Draw an arc between two nodes

    Expect preview aimed at both centres, arc at its own point once dropped

Labs sliders: canvas follows a slider, values are stored
  • Menu > Load example > Supply Chain With Disruption
  • Menu > User settings > Labs
    • Drag Spacing to 40 px

      Expect arcs on canvas to spread while dragging

  • Reload page
  • Menu > User settings > Labs

    Expect Spacing at 40 px

    • Defaults > Restore

      Expect Spacing at 16 px and arcs closer together

Guide figures: side dial and playground on the docs preview
  • Open Arc routing on docs preview
  • Drag slider of first figure

    Expect side ranges around the node to shift

  • Drag a node in the playground

    Expect arcs routed again on every move

  • Reset

    Expect first layout back

kube added 2 commits December 3, 2026 16:36
The head of an arc is a sharp triangle, 9 units long and 10.5 wide, with
its back cut in by half a unit. The arc stops 4 units short of the node
it points at and runs its last 8.5 units straight, so the head sits on
its line.

The whole line of an arc stops inside its head, where the head is twice
as wide as the line, and that end is round. The distance follows from
the shape of the head, so the line cannot show beside or past a head of
another size. The round end is a stroke of no length, so the other end
of the line keeps its flat end.
Arcs met a node where the line between two centres crossed its outline, so
the arcs of a busy node shared points and lay on each other. The core now
routes them: each end takes a side of its node, the ends of a side stand at
even distances in the order of where they go, and each end turns towards its
other node and fans out from the middle of its side.

- Core: `placeArcEnds` and `getArcLine` in the layout layer, with the six
  routing values in one settings object that is read on every call. A
  routing reuses the one before, so a drag places only the nodes it reaches.
- Canvas: the arc layer routes through the core and reads the values from
  the `arcRouting` user setting. Settings › Labs has a slider for each value
  and a way back to the defaults.
- Docs: an Arc routing guide beside the code with two interactive figures,
  and a shared loader for figures that load when they come into view.

An arc being drawn still aims at the centres of its nodes, and moves to its
point among the other arcs when it is dropped.
@kube kube self-assigned this Dec 3, 2026
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hash Ready Ready Preview Dec 3, 2026 7:56pm UTC
petrinaut Ready Ready Preview Dec 3, 2026 7:56pm UTC
petrinaut-docs Ready Ready Preview Dec 3, 2026 7:56pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Dec 3, 2026 7:56pm UTC

Request Review

@github-actions github-actions Bot added area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team area/apps labels Dec 3, 2026

This branch was successfully deployed

3 active deployments
Preview – hash — ff9cfade Deployed Dec 3, 2026 by vercel[bot]
Preview – petrinaut — ff9cfade Deployed Dec 3, 2026 by vercel[bot]
Preview – petrinaut-docs — ff9cfade Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

2 participants