Compile a layer tree into a renderable :class:Scene.
Traverses the layer tree, resolves channels, applies transforms and scales,
and finalises per-view data frames so the result is ready to pass directly
to a rendering backend.
Parameters:
| Name |
Type |
Description |
Default |
root
|
Layer
|
The root :class:~hakowan.grammar.layer.Layer of the visualization.
|
required
|
Returns:
| Type |
Description |
Scene
|
A compiled :class:Scene containing one :class:View per leaf path in
|
Scene
|
|
Source code in hakowan/compiler/compile.py
| def compile(root: layer.Layer) -> Scene:
"""Compile a layer tree into a renderable :class:`Scene`.
Traverses the layer tree, resolves channels, applies transforms and scales,
and finalises per-view data frames so the result is ready to pass directly
to a rendering backend.
Args:
root: The root :class:`~hakowan.grammar.layer.Layer` of the visualization.
Returns:
A compiled :class:`Scene` containing one :class:`View` per leaf path in
the layer tree.
"""
# Step 1: condense each path from root to leaf in the layer tree into a view.
scene = condense_layer_tree_to_scene(root)
logger.debug(f"Created scene with {len(scene)} views")
# Step 2: carry out transform operations on each view.
for view in scene:
apply_transform(view)
# Step 3: preprocess channels.
for view in scene:
preprocess_channels(view)
# Step 4: process channels, apply scales.
for view in scene:
process_channels(view)
# Step 5: finalize the data frame.
for view in scene:
view.finalize()
# Step 6: compute the global scene transform
scene.compute_global_transform()
return scene
|