Animator

The Animator widget allows you to animate the child widget over time.

It requires you to provide the duration, the child widget and a callback that will be called every frame.

This code snippet would animate the font size of a text widget from 0.0 to 30.0 over 2.0 seconds:

let font_size = context.use_state(0.0);;

Animator::new(
    Duration::from_millis(2000),
    Text::new("Hello World!".to_string()).with_font_size(font_size.maybe()),
    move |_, f| {
        // `f` is a value between `0.0` and `1.0` based on the time passed.
        font_size.set(f * 30.0);

        Update::DRAW
    },
)

For a full example, see the animation example.