| Crates.io | interpolated |
| lib.rs | interpolated |
| version | 0.1.2 |
| created_at | 2025-07-05 13:04:49.779966+00 |
| updated_at | 2025-07-05 16:11:42.896242+00 |
| description | Generic, smooth value interpolation and easing functions for Rust. |
| homepage | |
| repository | https://github.com/staninna/interpolated |
| max_upload_size | |
| id | 1739071 |
| size | 20,160 |
Generic, smooth value interpolation and easing functions for Rust.
T: Copy + Add + Sub + Mul<f32> over timenone (instant jump)linearease_in_out_expoease_out_backease_in_backease_out_elasticAdd to your Cargo.toml:
[dependencies]
interpolated = "0.1.2"
Or via the command line:
cargo add interpolated
use interpolated::{Interpolated, ease_out_elastic, linear};
use std::time::Duration;
fn main() {
// Create an interpolator for f32 values
let mut interp = Interpolated::new(0.0f32);
// Animate over 1 second
interp.set_duration(Duration::from_secs_f32(1.0));
// Choose easing curve
interp.transition = ease_out_elastic;
// Set target value
interp.set(10.0);
// In your update loop...
while !interp.is_finished() {
let current = interp.value();
println!("Value: {:.2}", current);
std::thread::sleep(Duration::from_millis(100));
}
// Final value reached
assert_eq!(interp.value(), 10.0);
}
struct Interpolated<T>new(initial: T) -> Selfset_duration(&mut self, duration: Duration)pub transition: fn(f32) -> f32set(&mut self, new_end: T)value(&self) -> Tis_finished(&self) -> booluse interpolated::{
none, linear, ease_in_out_expo,
ease_out_back, ease_in_back, ease_out_elastic,
};
Each function has the signature fn(f32) -> f32, mapping t ∈ [0,1] to an eased ratio.
For full docs, see https://docs.rs/interpolated
Licensed under: