Skip to content

Floating Edges

Floating edges ignore the handles and attach to the point on each node's border that faces the other node, worked out again on every render. An EdgeTemplate asks BlowGraphUtils.GetFloatingEdgeParams for the two points and sides, and BlowEdgePath.Compute turns them into a path of any type.

N1
N2
N3
N4
N5
bit Blow

Try it

  • Drag any outer node round N5: its edge slides along both borders, always joining the two points that face each other.
  • Drag N5 itself past the others: all four edges move to the sides that now face it.
  • Switch Path between Bezier, SimpleBezier, Straight, Step and SmoothStep: the same two points, joined by each algorithm.
  • Hover a node to show its two connection dots, then drag from one to another node: every dot that would take the connection lights up, and the new edge floats like the rest.

How it works

  • BlowGraphUtils.GetFloatingEdgeParams(source, target) returns where the line between the two nodes' centres crosses each node's bounding box, and which side of the node that is (Source, SourcePos, Target, TargetPos).
  • BlowEdgePath.Compute(type, sx, sy, sourcePos, tx, ty, targetPos, options) runs any built-in path algorithm between two points and returns a BlowPathResult - the SVG Path and the label point. The edge's own PathOptions go in as the last argument, so tuning an edge still works.
  • The EdgeTemplate hands that path to BlowBaseEdge instead of the handle-to-handle ctx.Path, and passes ctx.MarkerEndUrl on so the edges keep their arrowheads.
  • The geometry meets each node's bounding box, so the nodes are rounded squares rather than circles, whose borders the edges would stop short of on the diagonals.
  • ConnectionMode.Loose lets a connection start or end on either dot, since the handle it uses does not decide where the edge attaches. EdgesReconnectable is off for the same reason.
An unhandled error has occurred. Reload 🗙