节点与结果类型¶
Python 类型层定义了节点输入、测量结果和动画场景。
AnimationScene.duration_ms 和 RawAnimationFrame.duration_ms 必须为正。原始动画帧
还要求尺寸为正,并且恰好包含 width * height * 4 个 RGBA 字节。
RawRgbaImage 描述用作 ImageNode.src 的、已解码的按行优先 RGBA 像素。它的字节长度
遵循同样的 width * height * 4 约定。
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. |