This is a pure V module that provides easing function calculations.
vpkg get veasing
v install jamestomasino.veasing
cd path/to/your/project
git clone https://github.com/jamestomasino/veasing
cd path/to/your/project
git submodule add https://github.com/jamestomasino/veasing veasing && git submodule update --init --recursive
import veasing
import jamestomasino.veasing as veasing
Use the animate
function to apply an easing function over a range of numbers
fn main () {
println(veasing.animate(veasing.bounce_ease_out, 0, 100, 100))
// easing function ^
// lower bounds ^
// upper bounds ^
// number of frames/length of return array ^
}
The following easing methods are available:
veasing.linear_interpolation(p f64) f64
veasing.quadratic_ease_in(p f64) f64
veasing.quadratic_ease_out(p f64) f64
veasing.quadratic_ease_in_out(p f64) f64
veasing.cubic_ease_in(p f64) f64
veasing.cubic_ease_out(p f64) f64
veasing.cubic_ease_in_out(p f64) f64
veasing.quartic_ease_in(p f64) f64
veasing.quartic_ease_out(p f64) f64
veasing.quartic_ease_in_out(p f64) f64
veasing.quintic_ease_in(p f64) f64
veasing.quintic_ease_out(p f64) f64
veasing.quintic_ease_in_out(p f64) f64
veasing.sine_ease_in(p f64) f64
veasing.sine_ease_out(p f64) f64
veasing.sine_ease_in_out(p f64) f64
veasing.circular_ease_in(p f64) f64
veasing.circular_ease_out(p f64) f64
veasing.circular_ease_in_out(p f64) f64
veasing.exponential_ease_in(p f64) f64
veasing.exponential_ease_out(p f64) f64
veasing.exponential_ease_in_out(p f64) f64
veasing.elastic_ease_in(p f64) f64
veasing.elastic_ease_out(p f64) f64
veasing.elastic_ease_in_out(p f64) f64
veasing.back_ease_in(p f64) f64
veasing.back_ease_out(p f64) f64
veasing.back_ease_in_out(p f64) f64
veasing.bounce_ease_in(p f64) f64
veasing.bounce_ease_out(p f64) f64
veasing.bounce_ease_in_out(p f64) f64
To run the tests execute the following command from inside the cloned repo.
v -stats veasing_test.v
Based on the works of: