Package-level declarations

The tree: the sealed Node with its two kinds — ShapeNode, a styled, tagged leaf that subclasses its CGA shape, and GroupNode, an ordered sub-tree with optional bounds. A leaf reads and operates as its shape: geometric operations accept it as-is, and the shape-preserving ones (*, the coerce pair, canonical) return through the leaf's copy override — the leaf comes back as its own class, style and tags riding along; everything else returns plain shapes — the decoration drops by contract. This package adds the ShapeNode * Versor dispatch for leaves typed only as ShapeNode, and GroupNode * Versor over whole sub-trees — generic over the receiver and returning through the group's own copy hook, so a GroupNode subclass comes back as its own class too.

ShapeNode itself is not sealed; every leaf belongs to one of the two sealed families one package down — PrimitiveNode, the blade leaves, and CompositeNode, the composite leaves — so exhaustive dispatch splits on the families and nests a when over each.

The node-preserving transforms

PairingResult
node * Versorthe leaf with its geometry moved — each leaf class comes back as itself, style and tags untouched; the ShapeNode-typed dispatch widens the static type only
GroupNode * Versorthe group with every leaf in the sub-tree moved — structure, order, styles, and bounds preserved; a group subclass comes back as its own class through its copy hook

Types

Link copied to clipboard
open class GroupNode(val children: List<Node> = emptyList(), val bounds: SceneBounds? = null) : Node

A sub-tree of the scene graph: an ordered list of child nodes, with an optional bounds rectangle. A whole scene is just a GroupNode — the root's bounds is the viewport renderers paint into.

Link copied to clipboard
sealed interface Node

A node of the renderer-neutral scene graph — a sealed marker with exactly two kinds: ShapeNode, a styled leaf that is itself a CGA shape, and GroupNode, an ordered sub-tree.

Link copied to clipboard
interface ShapeNode : Node

A leaf of the scene graph: a CGA shape carrying the concrete style it renders with, plus optional tags.

Functions

Link copied to clipboard
fun backdrop(bounds: SceneBounds, color: ShapeColor = ShapeColor.BLACK): GroupNode

Builds a group holding one full-bleed color-filled rectangle over bounds — a prebuilt scene backdrop, usable directly as a placeholder scene or nested as a scene's first child.

Link copied to clipboard

Returns every ShapeNode in the tree — a depth-first, source-order traversal, so the resulting order is the paint order.

Link copied to clipboard
inline fun <N : ShapeNode> GroupNode.single(): N

Returns the tree's single leaf narrowed to its concrete node type N.

Link copied to clipboard
operator fun <G : GroupNode> G.times(versor: Versor): G

GroupNode * Versor => GroupNode
Returns this group with versor's motion applied to every leaf in the sub-tree.

operator fun ShapeNode.times(versor: Versor): ShapeNode

node * Versor => ShapeNode
Returns this leaf with versor's motion applied to its geometry — style and tags untouched.