Skip to main content

ranim_anims/
lib.rs

1//! Ranim's built-in animation families.
2//!
3//! Each module contains named, closed-form animation types plus the
4//! convenience traits used to construct them from an item (e.g.
5//! [`fading::FadingAnim`]). Every animation type implements
6//! [`Eval`](ranim_core::animation::eval::Eval) directly; composition
7//! containers (`AnimSequence`, `AnimStack`, `AnimLagged`) live in
8//! [`ranim_core::animation::compose`], and generic authoring adapters live in
9//! `ranim_core::animation`:
10//!
11//! - [`Pure`](ranim_core::animation::eval::pure::Pure) wraps a raw
12//!   `Fn(f64) -> T` closure into an `Eval`;
13//! - [`Iterative`](ranim_core::animation::eval::iterative::Iterative) turns an
14//!   [`IterativeEval`](ranim_core::animation::eval::iterative::IterativeEval) step function
15//!   into a stateful `Eval`.
16//!
17//! A built-in animation is a struct that implements `Eval` together with the
18//! data its closed form needs. For example, [`fading::FadeIn`]:
19//!
20//! ```rust,ignore
21//! pub struct FadeIn<T: FadingRequirement> {
22//!     src: T,
23//!     dst: T,
24//! }
25//!
26//! impl<T: FadingRequirement> Eval for FadeIn<T> {
27//!     type Output = T;
28//!
29//!     fn eval_alpha(&self, alpha: f64) -> Self::Output {
30//!         self.src.lerp(&self.dst, alpha)
31//!     }
32//! }
33//! ```
34//!
35//! Construction traits mutate the source item to its end state while building
36//! the animation:
37//!
38//! ```rust,ignore
39//! pub trait FadingAnim: FadingRequirement + Sized + 'static {
40//!     fn fade_in(&mut self) -> FadeIn<Self>;
41//!     fn fade_out(&mut self) -> FadeOut<Self>;
42//! }
43//!
44//! impl<T: FadingRequirement + Sized + 'static> FadingAnim for T {
45//!     fn fade_in(&mut self) -> FadeIn<Self> {
46//!         FadeIn::new(self.clone()).apply_to(self)
47//!     }
48//!
49//!     fn fade_out(&mut self) -> FadeOut<Self> {
50//!         FadeOut::new(self.clone()).apply_to(self)
51//!     }
52//! }
53//! ```
54#![warn(missing_docs)]
55#![cfg_attr(docsrs, feature(doc_cfg))]
56#![allow(rustdoc::private_intra_doc_links)]
57#![doc(
58    html_logo_url = "https://raw.githubusercontent.com/AzurIce/ranim/refs/heads/main/assets/ranim.svg",
59    html_favicon_url = "https://raw.githubusercontent.com/AzurIce/ranim/refs/heads/main/assets/ranim.svg"
60)]
61
62/// Camera frame animations.
63pub mod camera;
64/// Creation animations.
65pub mod creation;
66/// Fading animations.
67pub mod fading;
68/// Morph animations.
69pub mod morph;
70/// Rotating animations.
71pub mod rotating;