2 stable releases

1.0.1 Jan 12, 2023
1.0.0 Aug 20, 2021

#664 in Algorithms

Download history 725/week @ 2024-08-03 851/week @ 2024-08-10 1278/week @ 2024-08-17 1329/week @ 2024-08-24 1201/week @ 2024-08-31 964/week @ 2024-09-07 1167/week @ 2024-09-14 1488/week @ 2024-09-21 2689/week @ 2024-09-28 3147/week @ 2024-10-05 3873/week @ 2024-10-12 1094/week @ 2024-10-19 767/week @ 2024-10-26 1149/week @ 2024-11-02 808/week @ 2024-11-09 800/week @ 2024-11-16

3,668 downloads per month
Used in 13 crates (5 directly)

MIT/Apache

8KB
204 lines

simple-easing

This package contains a set of simple easing functions.


lib.rs:

This package contains a set of simple easing functions. That consume a standardised time attribute in the range between 0.0 and 1.0, that represent the progress of a transition. 0.0 being the beginning, 1.0 the end.

They return a value between 0.0 and 1.0 (it might exceed the 0..=1 range temporarily for a bounce effect). The returned value can be used to interpolate between the initial (0.0) and the final (1.0) transition state, allowing for a "more natural" feel of a transition by accelerating and decelerating at certain points, depending on the easing function used.

Visit easings.net to see visualisations of the different easing functions.

All easing functions have the same signature ((f32) -> f32) and can be easily stored as fn pointers.

use ::simple_easing::linear;
let easing: fn(f32) -> f32 = linear;
assert_eq!(easing(1.0), 1.0);

No runtime deps