motion-canvas-rs 0.2.2

A high-performance vector animation engine inspired by Motion Canvas, built on Vello and Typst.
Documentation
use super::all::All;
use crate::core::animation::base::Animation;

/// Runs multiple animations in parallel with a shared easing override.
///
/// `with_easing` creates an [`All`] container and immediately applies the
/// provided easing function to all child animations. This is useful for
/// grouping animations that should share the same motion feel.
///
/// Generally used via the [`with_easing!`](crate::with_easing) macro.
///
/// ### Example
/// ```rust
/// # use motion_canvas_rs::prelude::*;
/// # use std::time::Duration;
/// # let node = Rect::default()
/// #    .with_size(Vec2::new(100.0, 100.0))
/// #    .with_fill(Color::RED);
/// # let target = Vec2::new(100.0, 100.0);
/// # let dur = Duration::from_secs(1);
/// with_easing!(
///     easings::back_out,
///     [
///         node.position.to(target, dur),
///         node.size.to(Vec2::new(200.0, 200.0), dur),
///     ]
/// );
/// ```
pub fn with_easing(
    easing: fn(f32) -> f32,
    animations: Vec<Box<dyn Animation>>,
) -> Box<dyn Animation> {
    let mut all = All::new(animations);
    all.set_easing(easing);
    Box::new(all)
}