Geom

Geom :: # (opaque)

Geometry shared by every layout family: the output vocabulary (points, rectangles, routes) and the small helpers each family uses to build it.

saturate : F64 -> F64

A finite copy of a derived value: infinities saturate at the largest finite magnitude of their sign, and NaN — which derived arithmetic on finite inputs can only reach through an unguarded infinity — falls back to 0. Layout arithmetic applies this at its output seams so finite accepted input always produces finite geometry, however extreme.

hypot : F64, F64 -> F64

The length of the vector (x, y), computed by scaling before squaring so finite inputs give a finite result even near the F64 maximum, where squaring directly would overflow to infinity. When the true length itself exceeds the largest finite F64 (both components near the maximum), the result saturates at F64.highest — finite input never produces a non-finite length.

clip_to_node : { x : F64, y : F64 }, { width : F64, height : F64 }, { x : F64, y : F64 } -> Point

Where the segment from a node's center toward toward crosses the node's rectangular boundary — the attachment point a route endpoint should use, so arrowheads land on the box rather than inside it.

Defined for every input: a zero-size node clips to its own center, as does a toward equal to the center. The result always lies on the node's boundary (or at its center), whatever the distance to toward.

Point : { x : F64, y : F64 }

A position in the caller's units. x grows right, y grows down.

Rect : { x : F64, y : F64, width : F64, height : F64 }

An axis-aligned box: top-left corner plus full extents.

Route : [
    Line({ x : F64, y : F64 }, { x : F64, y : F64 }),
    Polyline(List({ x : F64, y : F64 })),
    Curves(
        List(
            {
                from : { x : F64, y : F64 },
                ctl_a : { x : F64, y : F64 },
                ctl_b : { x : F64, y : F64 },
                to : { x : F64, y : F64 },
            },
        ),
    ),
]

The one shape every edge route takes, in every family: a straight line, a chain of straight segments, or a chain of cubic curve segments. The union is closed by design — these three forms express every planar curve a renderer can draw, so new algorithms never force consumers to handle new route forms.