← circus

Animation Helper

Animation design made easier

Python Code

from vood import animations
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.atomic.fade(
        states[0], states[1], at_time=0.5, duration=0.4, extend_timeline=True
    )

    renderer = TextRenderer()

    element = VElement(
        renderer=renderer,
        keyframes=fade_keyframes,
        global_transitions={"color": (START_COLOR, END_COLOR)},
    )

    scene.add_element(element)

    # Create the exporter
    exporter = VSceneExporter(
        scene=scene,
        converter=ConverterType.PLAYWRIGHT,
        output_dir="output/",
    )

    # Export to mp4
    exporter.to_mp4(
        filename="animation_helper",
        total_frames=150,
        framerate=30,
        width_px=512,
    )


if __name__ == "__main__":
    main()



Remarks

  • Animation helpers don’t introduce anything new but provide a growing set of tools for creating keyframe sequences of common animation tasks.
  • Vood provides two types of animation helpers: atomic, which generate keyframes for a single element, and compound, which generate coordinated keyframes for multiple elements. These helper can be found in the vood.animation module.