Crate interpolated

Crate interpolated 

Source
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§

EasingFn
A function that maps (t \in [0,1]) to an eased ratio in ([0,1]).