Skip to content

fix: the word on a link sits on its curve - #174

Merged
endrix merged 3 commits into
mainfrom
fix/link-label-on-curve
Nov 12, 2026
Merged

endrix merged 3 commits into
mainfrom
fix/link-label-on-curve

Conversation

@endrix

@endrix endrix commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

A small correction to the links drawn on selection (#171), seen on a real render of a CalPy actor: the count on a token link (×1) hung in the air some 80 px from its link.

What changes

The word of a link was put at the middle of the straight line between the link's two ends. A link is a curve that leaves a node straight out of one side and arrives straight into a side of the other, so where those sides are not facing each other the curve runs well clear of that point. The word is now at the middle of the curve itself (the cubic at t = 0.5, from the same two control points the path is drawn with).

Checked

  • test/selection-links.test.ts: the middle is on the drawn curve; for a bowed link it is more than 40 px from the old place; for a straight link it is the middle of its line; the drawing puts the word there.
  • Typecheck and the client suite pass.

After review

An independent review checked the geometry for all sixteen pairs of sides against the drawn path, and swept 20,000 random fans of three labelled links. Nothing to fix before merge; two things taken from it:

  • The drawing's test passed with the old placement (its link was straight, where both middles coincide). It now draws a link bent by a neighbour of its frame, and fails if the word goes back to the chord.
  • A new, rare collision: two links leaving a node side by side, one around a corner and one straight through, had their words within 3 px of each other (62 of 20,000 fans; none before, because the corner link's word was off its curve). A word now moves along its own curve (to 0.38, 0.62, 0.26 or 0.74 of it) when the word of a link placed before it is within 14 px.

In the sweep, words over a node fell from 1,098 to 831; words more than 12 px off their own curve were 14,201 of 60,000 before this change.

https://claude.ai/code/session_01EToj6RJRMSSHQiqGNMU9wv

It was put at the middle of the straight line between the link's ends,
which a curve that leaves by a side and arrives from below runs well
clear of: the count on a token link hung in the air beside it.

Claude-Session: https://claude.ai/code/session_01EToj6RJRMSSHQiqGNMU9wv
…rd is tested where it is drawn

From the review of #174.

- Two links that leave a node side by side still run together halfway,
  so their words landed within a few pixels of each other once each sat
  on its own curve. A word now moves a little along its curve when the
  word of a link placed before it is already there.
- The test of the drawing used a straight link, whose middle is the same
  either way: it passed with the old placement. It now uses a link bent
  by a neighbour of its frame.

Claude-Session: https://claude.ai/code/session_01EToj6RJRMSSHQiqGNMU9wv
@endrix
endrix merged commit 1123e6d into main Nov 12, 2026
1 check passed
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