Pareen
Pareen is a small Rust library for parameterized inbetweening. The intended application is in game programming, where you sometimes have two discrete game states between which you want to transition smoothly for visualization purposes.
Pareen gives you tools for composing animations that are parameterized by time (i.e. mappings from time to some animated value) without constantly having to pass around time variables; it hides the plumbing, so that you need to provide time only once: when evaluating the animation.
Animations are composed similarly to Rust's iterators, so no memory allocations are necessary.
Usage
Just add this line to your dependencies in Cargo.toml
:
pareen = "0.1"
Examples
// An animation returning a constant value
let anim1 = constant;
// Animations can be evaluated at any time
let value = anim1.eval;
// Animations can be played in sequence
let anim2 = anim1.seq;
// Animations can be composed and transformed in various ways
let anim3 = anim2
.lerp
.scale_min_max
.backwards
.squeeze;
let anim4 = cubic - anim3;
let value = anim4.eval;
Easer
Optionally, you can enable support for integrating easing functions from
easer
.
let first_anim = constant;
let second_anim = prop;
// Transition from first_anim to second_anim at time 0.5, applying cubic easing
// for 0.3 time units.
let anim = first_anim.seq_ease_in_out;
Plots
There is an example that shows some animations as plots via
RustGnuplot in
examples/plots.rs. Given that gnuplot
has been
installed, it can be executed like this:
If everything works, you should see something like this: