eazy_tweener/
lib.rs

1//! eazy-tweener — GSAP-like animation runtime for Rust.
2//!
3//! Built on top of eazy-data's mathematical foundation (96 easing curves,
4//! interpolation functions, SIMD support), this crate provides a complete
5//! animation runtime with tweens, timelines, callbacks, and stagger support.
6//!
7//! # Examples
8//!
9//! ## Simple Tween
10//!
11//! ```rust
12//! use eazy_tweener::{Tween, Controllable};
13//! use eazy_core::Easing;
14//!
15//! let mut tween = Tween::to(0.0_f32, 100.0)
16//!   .duration(1.0)
17//!   .easing(Easing::OutBounce)
18//!   .on_complete(|| println!("Done!"))
19//!   .build();
20//!
21//! tween.play();
22//!
23//! // In your update loop:
24//! while tween.tick(0.016) {
25//!   let value = tween.value();
26//!   // Apply value to your target
27//! }
28//! ```
29//!
30//! ## Timeline with Sequencing
31//!
32//! ```rust
33//! use eazy_tweener::{Timeline, Tween, Position, Controllable};
34//!
35//! let mut timeline = Timeline::builder()
36//!   .push(Tween::to(0.0_f32, 100.0).duration(1.0).build())
37//!   .push_at(
38//!     Tween::to(0.0_f32, 50.0).duration(0.5).build(),
39//!     Position::WithPrevious
40//!   )
41//!   .push_at(
42//!     Tween::to(100.0_f32, 0.0).duration(1.0).build(),
43//!     Position::Relative(-0.2)
44//!   )
45//!   .build();
46//!
47//! timeline.play();
48//! ```
49//!
50//! ## Staggered Animations
51//!
52//! ```rust
53//! use eazy_tweener::{Timeline, Tween, Stagger, StaggerFrom, Controllable};
54//!
55//! let tweens: Vec<_> = (0..5)
56//!   .map(|_| Tween::to(0.0_f32, 100.0).duration(0.5).build())
57//!   .collect();
58//!
59//! let mut timeline = Timeline::builder()
60//!   .push_staggered(tweens, Stagger::each(0.1).from(StaggerFrom::Center))
61//!   .build();
62//!
63//! timeline.play();
64//! ```
65//!
66//! ## Custom Tweenable Types
67//!
68//! ```rust,ignore
69//! use eazy_tweener::Tweenable;
70//!
71//! #[derive(Clone, Copy, Tweenable)]
72//! struct Position {
73//!   x: f32,
74//!   y: f32,
75//! }
76//!
77//! let a = Position { x: 0.0, y: 0.0 };
78//! let b = Position { x: 100.0, y: 200.0 };
79//! let mid = a.lerp(b, 0.5);  // Position { x: 50.0, y: 100.0 }
80//! ```
81
82pub mod callback;
83pub mod control;
84pub mod position;
85pub mod repeat;
86pub mod stagger;
87pub mod timeline;
88pub mod tween;
89pub mod value;
90
91// Re-export main types at crate root.
92pub use callback::*;
93pub use control::*;
94pub use position::*;
95pub use repeat::*;
96pub use stagger::*;
97pub use timeline::*;
98pub use tween::*;
99pub use value::*;