8 releases
| new 0.5.1 | Apr 13, 2026 |
|---|---|
| 0.5.0 | Apr 10, 2026 |
| 0.4.0 | Apr 5, 2026 |
| 0.1.15 | Mar 22, 2026 |
| 0.1.12 | Jan 19, 2026 |
#149 in GUI
70 downloads per month
Used in 10 crates
(8 directly)
710KB
15K
SLoC
blinc_animation
Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
Animation system for Blinc UI - spring physics, keyframes, and timeline orchestration.
Overview
blinc_animation provides a powerful animation system with spring physics, keyframe animations, and timeline orchestration. All animations are interruptible and preserve velocity when interrupted.
Features
- Spring Physics: RK4-integrated springs with configurable stiffness, damping, and mass
- Keyframe Animations: Timed sequences with easing functions
- Timelines: Orchestrate multiple animations with offsets
- Interruptible: Animations inherit velocity when interrupted
- Presets: Common entry/exit animation patterns
Spring Animations
use blinc_animation::{Spring, SpringConfig};
// Create a spring
let spring = Spring::new(SpringConfig {
stiffness: 300.0,
damping: 20.0,
mass: 1.0,
});
// Animate to target
spring.animate_to(100.0);
// Update each frame
let value = spring.update(delta_time);
Spring Presets
SpringConfig::gentle() // Slow, gentle movement
SpringConfig::default() // Balanced default
SpringConfig::bouncy() // Playful bounce
SpringConfig::stiff() // Quick, snappy
Keyframe Animations
use blinc_animation::{KeyframeAnimation, Keyframe, Easing};
let animation = KeyframeAnimation::new()
.keyframe(Keyframe::new(0.0, 0.0))
.keyframe(Keyframe::new(0.5, 100.0).easing(Easing::EaseOut))
.keyframe(Keyframe::new(1.0, 80.0).easing(Easing::EaseInOut))
.duration(Duration::from_millis(500));
// Update each frame
let value = animation.update(delta_time);
Easing Functions
Easing::Linear
Easing::EaseIn
Easing::EaseOut
Easing::EaseInOut
Easing::CubicBezier(0.4, 0.0, 0.2, 1.0)
Timelines
use blinc_animation::{Timeline, TimelineEntry};
let timeline = Timeline::new()
.add(opacity_animation, Duration::ZERO)
.add(scale_animation, Duration::from_millis(100))
.add(position_animation, Duration::from_millis(200));
// Play/pause/seek
timeline.play();
timeline.pause();
timeline.seek(Duration::from_millis(150));
Animation Scheduler
use blinc_animation::AnimationScheduler;
// Global scheduler manages all active animations
let scheduler = AnimationScheduler::global();
// Schedule an animation
scheduler.schedule(animation);
// Update all animations
scheduler.update(delta_time);
Multi-Property Animation
use blinc_animation::AnimatedValue;
struct AnimatedElement {
x: AnimatedValue<f32>,
y: AnimatedValue<f32>,
opacity: AnimatedValue<f32>,
scale: AnimatedValue<f32>,
}
impl AnimatedElement {
fn animate_to(&mut self, x: f32, y: f32) {
self.x.animate_to(x);
self.y.animate_to(y);
}
fn update(&mut self, dt: f32) {
self.x.update(dt);
self.y.update(dt);
self.opacity.update(dt);
self.scale.update(dt);
}
}
Presets
use blinc_animation::presets;
// Entry animations
presets::fade_in()
presets::slide_in_left()
presets::slide_in_right()
presets::scale_in()
presets::bounce_in()
// Exit animations
presets::fade_out()
presets::slide_out_left()
presets::slide_out_right()
presets::scale_out()
License
MIT OR Apache-2.0
Dependencies
~5–10MB
~113K SLoC