Skip to main content

Hierarchy

Node data access and layout scripting.

Runtime baseline

NodeReadData.paint, node:asPath(), and node:asPaint() remain tracked as live in the June 4, 2026 compatibility baseline. See Runtime Compatibility Baseline for the current npm line and source pins. See Runtime Compatibility Baseline for tracked status.


NodeData

Writable node data with transform properties and hierarchy access.

Attributes

node.children

Child nodes. Type: table of NodeData (read-only)

node.parent

Parent node, or nil if root. Type: NodeData? (read-only)

Methods

node:decompose(worldTransform)

Updates position, rotation, and scale from a world transform matrix.

node:decompose(worldTransform: Mat2D)

See Also: NodeReadData


NodeReadData

Read-only node data providing transform properties.

Attributes

AttributeTypeDescription
positionVectorLocal position
rotationnumberLocal rotation in radians
scaleVectorLocal scale
worldTransformMat2DWorld transform matrix
xnumberLocal position X
ynumberLocal position Y
scaleXnumberLocal scale X
scaleYnumberLocal scale Y
paintPaint?Paint data (if ShapePaint node)

Methods

node:asPath()

Casts the node to its PathData representation. Returns nil if not a path node.

node:asPath(): PathData?

node:asPaint()

Casts the node to its Paint representation. Returns nil if not a ShapePaint node.

node:asPaint(): Paint?

See Also: NodeData, Mat2D, PathData


Layout

Scripted layout that fits into layout boxes.

Protocol Methods

measure(self)

Optional. Enables intrinsic sizing. After measurement, resize() is called with granted dimensions.

function measure(self: MyLayout): Vector
-- Request specific size (may be constrained by min/max)
return Vector.xy(100, 100)
end

resize(self, size)

Required. Called on initial size and whenever size changes.

function resize(self: MyLayout, size: Vector)
self.width = size.x
self.height = size.y
end

Note: Layout extends the Node protocol. Layout scripts inherit all Node callbacks (init, advance, draw, pointer event handlers) in addition to measure and resize.

Next Steps