| Crates.io | easing-fixed |
| lib.rs | easing-fixed |
| version | 0.1.1 |
| created_at | 2025-01-11 22:18:33.50942+00 |
| updated_at | 2025-01-13 02:38:37.023464+00 |
| description | easing iterators using fixed-point math |
| homepage | |
| repository | https://github.com/spookyvision/easing-fixed |
| max_upload_size | |
| id | 1512785 |
| size | 41,219 |
easing-fixed: fixed-point easing iterators for rustThis is a fork of https://github.com/joliv/easing which uses fixed-point math instead. no_std compatible.
at(t, start, distance) and at_normalized(t) methods if you don't want iterators:use easing_fixed::{Fix, ExpInOut};
let res = ExpInOut::at(Fix::from_num(0.5), Fix::from_num(10.), Fix::from_num(100)); // range is 10..=110, result is 60
let res = ExpInOut::at_normalized(Fix::from_num(0.75)); // range is 0..1, result is 0.984375
The test cases define an acceptable error margin (ERROR_MARGIN_FAC) and every test case stepping outside of that threshold gets its "is" and "ought" data written to jupyter-tests/<name of test>-{is,ought}.json. In there, you can use the supplied tests.ipynb notebook for a visualized representation of the failure:

The JSON files get cleared out by build.rs. Sadly on every build, not just during tests, as cfg-gating for test is not possible there.
Rust iterators are fantastic—why not use them for easing? Use like so:
use easing_fixed as easing;
let begin: f64 = 0;
let end: f64 = 1000;
let steps: u64 = 10;
// In a for loop!
for x in easing::sin_in(begin, end, steps) {
println!("Woo, I'm at x={}!", x);
}
// Mapping!
fn move_to(x: f64) {
println!("Moving on up to {}", x);
}
easing::cubic_out(begin, end, steps).map(move_to);
// And other iterator stuff!
let xs: Vec<f64> = easing::exp_inout(begin, end, steps).collect(); // why would you do this
Available iterators are currently:
| function | in | out | in and out |
|---|---|---|---|
| linear | linear |
linear |
linear |
| quadratic | quad_in |
quad_out |
quad_inout |
| cubic | cubic_in |
cubic_out |
cubic_inout |
| quartic | quartic_in |
quartic_out |
quartic_inout |
| sinusoidal | sin_in |
sin_out |
sin_inout |
| exponential | exp_in |
exp_out |
exp_inout |
Easing functions taken from warrenm's AHEasing.