Nodes and result types¶
The Python type layer defines node inputs, measurement results, and animation scenes.
AnimationScene.duration_ms and RawAnimationFrame.duration_ms must be positive.
Raw animation frames also require positive dimensions and exactly
width * height * 4 RGBA bytes.
RawRgbaImage describes decoded row-major RGBA pixels used as an ImageNode.src.
Its byte length follows the same width * height * 4 contract.
takumi_py.types.TextNode ¶
takumi_py.types.ImageNode ¶
Bases: NodeBase
An image leaf node.
Attributes:
| Name | Type | Description |
|---|---|---|
src |
str | bytes | RawRgbaImage
|
Image identifier, encoded image bytes, or raw RGBA pixels. |
width |
NotRequired[float]
|
Rendered width in CSS pixels. |
height |
NotRequired[float]
|
Rendered height in CSS pixels. |
takumi_py.types.RawRgbaImage ¶
Bases: TypedDict
Raw row-major RGBA pixels used directly as an image node source.
Attributes:
| Name | Type | Description |
|---|---|---|
width |
int
|
Image width in pixels. |
height |
int
|
Image height in pixels. |
data |
bytes
|
Exactly |
premultiplied |
NotRequired[bool]
|
Whether RGB channels already include alpha
multiplication. Defaults to |
takumi_py.types.ContainerNode ¶
takumi_py.types.MeasuredNode
dataclass
¶
An immutable node in a measured layout tree.
Attributes:
| Name | Type | Description |
|---|---|---|
width |
float
|
Box width in layout units. |
height |
float
|
Box height in layout units. |
transform |
tuple[float, float, float, float, float, float]
|
Six values for the node's 2D affine transform. |
children |
tuple[MeasuredNode, ...]
|
Measured child nodes. |
runs |
tuple[MeasuredTextRun, ...]
|
Text runs laid out directly on this node. |
__init__ ¶
__init__(
width: float,
height: float,
transform: tuple[
float, float, float, float, float, float
],
children: tuple[MeasuredNode, ...],
runs: tuple[MeasuredTextRun, ...],
) -> None
takumi_py.types.MeasuredTextRun
dataclass
¶
takumi_py.types.AnimationScene
dataclass
¶
One timed scene in a rendered animation sequence.
Attributes:
| Name | Type | Description |
|---|---|---|
node |
NodeInput | CompiledNode
|
A Python node mapping or an already compiled node. |
duration_ms |
int
|
Positive scene duration in milliseconds. |
takumi_py.types.RawAnimationFrame
dataclass
¶
A pre-rendered RGBA frame for Renderer.encode_frames.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
bytes
|
Exactly |
width |
int
|
Frame width in pixels. |
height |
int
|
Frame height in pixels. |
duration_ms |
int
|
Positive frame duration in milliseconds. |
takumi_py.types.validate_node ¶
Validate and normalize a node mapping in Python.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
object
|
A mapping with a |
required |
Returns:
| Type | Description |
|---|---|
Node
|
A typed node mapping normalized through msgspec. |
Raises:
| Type | Description |
|---|---|
NodeValidationError
|
If the mapping does not match a supported node shape. |