Expand description
§interpolated
Generic, smooth value interpolation and easing functions for Rust.
This crate provides the Interpolated<T> type for animating values of any
arithmetic type over time using customizable easing functions.
§Usage
Add to your Cargo.toml:
[dependencies]
interpolated = "0.1.0"Import and use in code:
use interpolated::{Interpolated, linear};
use std::time::Duration;
let mut value = Interpolated::new(0.0f32);
value.set_duration(Duration::from_secs_f32(1.0));
value.transition = linear;
value.set(10.0);
// In an update loop:
let current = value.value();
println!("Current: {}", current);Structs§
- Interpolated
- A value that interpolates smoothly from a start to an end over time using an easing function.
Functions§
- ease_
in_ back - Ease in “back”.
- ease_
in_ out_ expo - Ease in/out exponential.
- ease_
out_ back - Ease out “back”.
- ease_
out_ elastic - Ease out “elastic”.
- linear
- Linear easing.
- none
- “No animation” (always jump to the end).
Type Aliases§
- Easing
Fn - A function that maps (t \in [0,1]) to an eased ratio in ([0,1]).