← circus
Compound Animations
Generate coordinated keyframes for multiple elements
Python Code
from vood import animations
from vood.transitions import easing
from vood.components import TextRenderer, TextState
from vood.converter.converter_type import ConverterType
from vood.tat.logger import configure_logging
from vood.velements import VElement
from vood.vscene import VScene
from vood.vscene.vscene_exporter import VSceneExporter
configure_logging(level="INFO")
START_COLOR = "#FDBE02"
END_COLOR = "#AA0000"
def main():
# Create the scene
scene = VScene(width=256, height=256, background="#000017")
# Create text states for each number with consistent styling
# These states will be the starting point of the animation
states = [
TextState(
text=text,
font_family="Courier",
font_size=42,
)
for text in ["Empty", "Mirror"]
]
fade_keyframes = animations.compound.slide_replace(
state1=states[0],
state2=states[1],
at_time=0.5,
duration=0.4,
distance=100,
direction=animations.compound.SlideDirection.UP,
extend_timeline=True,
)
renderer = TextRenderer()
opacity_easing = (easing.in_cubic, easing.out_cubic)
elements = [
VElement(
renderer=renderer,
keyframes=keyframes,
global_transitions={"color": (START_COLOR, END_COLOR)},
easing={"opacity": opacity_easing[i]},
)
for i, keyframes in enumerate(fade_keyframes)
]
scene.add_elements(elements)
# Create the exporter
exporter = VSceneExporter(
scene=scene,
converter=ConverterType.PLAYWRIGHT,
output_dir="output/",
)
# Export to mp4
exporter.to_mp4(
filename="compound_animation",
total_frames=150,
framerate=30,
width_px=512,
)
if __name__ == "__main__":
main()
Remarks
- Compound animations generate keyframes for multiple elements to orchestrate more complex animations.