Home
API: forms

Function: bounds()

lifecycle-kit

lifecycle-kit


lifecycle-kit / forms / bounds

Function: bounds()

bounds(path): { max: Vec2; min: Vec2; } | null

Defined in: forms/path.ts:426

The bounding box of a path, or null when it has no shapes.

Exact for every member of the segment vocabulary, which is the reason it is here rather than in a renderer. Tests assert extents — "a taper narrows", "a radiate is symmetric about its hub" — and an approximate bound computed from control points would make those assertions fuzzy in precisely the way vectors were chosen to avoid.

Control points of a Bézier are NOT on the curve, so including them directly would overstate the box. The curve is solved instead: the extremum of a Bézier lies at an endpoint or where its derivative crosses zero, so the derivative roots within (0, 1) are evaluated and included.

Parameters

path

Path

Returns

{ max: Vec2; min: Vec2; } | null