Skip to main content

Module ports

Module ports 

Source
Expand description

Seat-based ports: discrete connection points packed around a node’s rounded rim, and the curves between them.

This is an alternative to crate::Handle-based anchoring for editors where connections may attach anywhere on a node’s border: a rim offers a whole number of seats one SEAT_PITCH apart, solve_ports packs every connection end into a seat of its own (deterministically, so the same graph always renders the same), and edge_geometry draws the curve between two seats, arrowheads and label anchor included.

Everything here is headless — pure geometry over keyed rectangles — so it can drive custom edge layers, exports and thumbnails alike.

Structs§

Anchor
Arrows
Which ends of a connection carry an arrowhead. The plane only needs to know which ends to leave room for; what an arrow means belongs to the application.
EdgeAnchors
EdgeGeometry
Link
PortSeat
One of the discrete places on a node’s rim where a bead may rest.

Enums§

Endpoint
Side
Re-exported for convenience: a seat names its face with the shared Side type. A side of a node, used for handle placement, seat naming and edge routing.
Terminal

Constants§

CORNER_RADIUS
How rounded a node’s corners are. The stylesheet has to agree with this, or beads will sit off the rim they are packed onto.
DEFAULT_LABEL_POSITION
Where a label rests until it is moved.
MAX_LABEL_POSITION
MIN_LABEL_POSITION
How near a connection’s end a label may be dragged. A label exactly on the end would sit under the arrowhead and the node both.
PORT_RADIUS
The bead’s own radius, which the surface draws and this reserves room for.
SEAT_PITCH
How far apart the seats on a node’s rim are, and so the least room any two beads can have between them.

Functions§

clamp_seat
The nearest seat this frame actually has to the one asked for. A node shrunk past one of its own ports leaves that port at the corner rather than off the end of the rim.
edge_geometry
nearest_free_seat
The seat nearest a point that nothing is sitting in yet.
nearest_on_ring
nearest_seat
The seat nearest a point, which is what a dragged bead lands on.
ring_length
ring_point
seat_point
Where a seat sits on the rim, with the outward normal a connection leaves along. The seat names a point on the plain rectangle; the rim itself is rounded, so a corner seat resolves onto its arc.
seats
Every seat a frame offers, walking the rim clockwise from the top-left corner. The four corners belong to the horizontal runs, so no place on the rim is named twice.
solve_ports