Box
Boxes as layout projection works with them: two axes, each the interval it spans, { min, max }, so
every projection formula is one function per axis, applied twice. A measured Probe.Bounds becomes a
Box once, with fromBounds, and turns back with toBounds where something needs bounds again; mix
blends one box toward another, as a layout animation does each frame.
import * as Box from "@wardic/core/Box"
const box = Box.fromBounds(bounds)
Box.length(box.x) // its width
const halfway = Box.mix(from, to, 0.5)Interfaces
Axis
One axis of a box, as the interval it spans: its left and right edges across, its top and bottom down.
Properties
max
readonly max: number;Where it ends: the right edge, or the bottom.
min
readonly min: number;Where it starts: the left edge, or the top.
Box
A box as two axes: the interval it spans across, and the one down.
Properties
x
readonly x: Axis;Across: left to right.
y
readonly y: Axis;Down: top to bottom.
Functions
fromBounds()
function fromBounds(b): Box;A measured Probe.Bounds as a Box: across from its left edge to its right, down from its top to its bottom.
Parameters
b
Returns
length()
function length(axis): number;How long an axis is: max - min, the box's width or height.
Parameters
axis
Returns
number
mix()
function mix(
from,
to,
progress
): Box;A box progress of the way from from to to, as a layout animation draws it each frame.
Parameters
from
to
progress
number
Returns
mixAxis()
function mixAxis(
from,
to,
progress
): Axis;An axis progress of the way from from to to: from at 0, to at 1.
Parameters
from
to
progress
number
Returns
toBounds()
function toBounds(box): Bounds;A Box as Probe.Bounds, its x and y at its top-left corner: for what needs bounds again.