Floating Edges — rataflow

rataflow

GitHubdocs.rscrates.io
examples/floating_edges.rs ↗

Edges that re-pick their sides as the nodes move.

An ordinary edge attaches to the handles its nodes declare and stays there, however they are arranged — on default nodes that means leaving the source's right and arriving on the target's left, even for a node sitting directly above. FloatingEdge derives its endpoints from the node rectangles instead, re-picking every frame as the nodes move.

Press a to cycle four attachments and drag a node under each:

  1. FloatingEdge, stepped — the middle of whichever side faces the target
  2. FloatingEdge, straight — where the line between the two centers crosses the outline, so the endpoint slides as the node moves
  3. The same straight edge with FloatingAttachment::Midpoint — back to snapping, for comparison
  4. StepEdge — the handles the nodes declare, wherever the target is

Two and three are the pair worth watching, and they differ by one field. Route and attachment are separate settings on FloatingEdge: each route has the attachment that suits it by default (a straight edge draws in braille, which has the sub-cell resolution to show an endpoint sliding; a stepped one draws in box-drawing characters, which do not), and either can take the other.

Nothing is declared to make any of this work — no handles on the relevant sides, no flag on the edge or the graph. The ● markers show where the handles are; the floating variants ignore them, which is the point.