Skip to content

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

Bases: NodeBase

type instance-attribute

type: Literal['text']

text instance-attribute

text: str

takumi_py.types.ImageNode

Bases: NodeBase

type instance-attribute

type: Literal['image']

src instance-attribute

src: str | bytes | RawRgbaImage

width instance-attribute

width: NotRequired[float]

height instance-attribute

height: NotRequired[float]

takumi_py.types.RawRgbaImage

Bases: TypedDict

Raw row-major RGBA pixels used directly as an image node source.

width instance-attribute

width: int

height instance-attribute

height: int

data instance-attribute

data: bytes

premultiplied instance-attribute

premultiplied: NotRequired[bool]

takumi_py.types.ContainerNode

Bases: NodeBase

type instance-attribute

type: Literal['container']

children instance-attribute

children: NotRequired[list[Node]]

takumi_py.types.MeasuredNode dataclass

width instance-attribute

width: float

height instance-attribute

height: float

transform instance-attribute

transform: tuple[float, float, float, float, float, float]

children instance-attribute

children: tuple[MeasuredNode, ...]

runs instance-attribute

runs: tuple[MeasuredTextRun, ...]

__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

text instance-attribute

text: str

x instance-attribute

x: float

y instance-attribute

y: float

width instance-attribute

width: float

height instance-attribute

height: float

__init__

__init__(
    text: str,
    x: float,
    y: float,
    width: float,
    height: float,
) -> None

takumi_py.types.AnimationScene dataclass

node instance-attribute

node: NodeInput | CompiledNode

duration_ms instance-attribute

duration_ms: int

__init__

__init__(
    node: NodeInput | CompiledNode, duration_ms: int
) -> None

takumi_py.types.RawAnimationFrame dataclass

data instance-attribute

data: bytes

width instance-attribute

width: int

height instance-attribute

height: int

duration_ms instance-attribute

duration_ms: int

__init__

__init__(
    data: bytes, width: int, height: int, duration_ms: int
) -> None

takumi_py.types.validate_node

validate_node(node: object) -> Node