@fogrexon/glyph-arena-transform

Per-node local 2D transforms and world matrix composition. See also package README.

Exports

Generated from the package's source when the docs are built — do not edit this table by hand.

NameKind
LocalTransformtype
Matrix2Dtype
Transformtype
createTransformfunction

createTransform()

const transform = createTransform();

transform.set(node, { x: 10, y: 20 });
const local = transform.get(node);
transform.clear(node);
const matrix = transform.world(node, (n) => parentOf(n));
transform.dispose();

Methods

LocalTransform

FieldDefaultDescription
x0translation X
y0translation Y
rotation0rotation in radians
scaleX1horizontal scale
scaleY1vertical scale

Matrix2D

Canvas 2D affine matrix (a, b, c, d, e, f) compatible with CanvasRenderingContext2D.setTransform.

Node identity

Nodes are keyed by object identity in a WeakMap. Primitives and null are not stored.

Local matrix

Each local transform composes as translation × rotation × scale into a Matrix2D.

world(node, parentOf)

parentOf walks from node toward ancestors. The walk stops when parentOf returns a non-object, or when the next parent would revisit an object already on the chain (cycle); the revisiting node is treated as the root of the remaining chain.

The world matrix is built from that root down: start with the root’s local matrix, then multiply each descendant’s local matrix in order down to node.

If parentOf throws, the error propagates.

After dispose()