nova-easing
A collection of generic easing functions, supporting portable SIMD.
This crate provides a variety of easing functions that can be applied to scalar
types (f32, f64) and, with the nightly feature, to SIMD vectors from
std::simd.
Compare easings.net
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
Scalar Easing
The easing functions can be used on f32 and f64 values.
use EasingArgument;
SIMD Easing (Nightly Only)
To use easing functions with std::simd types, you need to enable the nightly
feature in your Cargo.toml and use a nightly Rust toolchain.
[]
= { = "0.1.0", = ["nightly"] }
Then you can apply easing functions to SIMD vectors:
use EasingArgument;
use f32x4;
API Overview
The crate provides easing functions for f32, f64, and SIMD types (f32x4,
f64x4, etc. with nightly feature).
All easing functions follow the pattern ease_{in|out|in_out}_{type}, where
type is one of: quad, cubic, quart, quint, sine, circ, back,
bounce, expo, elastic.
Available Functions
ease_in_quad,ease_out_quad,ease_in_out_quadease_in_cubic,ease_out_cubic,ease_in_out_cubicease_in_quart,ease_out_quart,ease_in_out_quartease_in_quint,ease_out_quint,ease_in_out_quintease_in_sine,ease_out_sine,ease_in_out_sineease_in_circ,ease_out_circ,ease_in_out_circease_in_back,ease_out_back,ease_in_out_backease_in_bounce,ease_out_bounce,ease_in_out_bounceease_in_expo,ease_out_expo,ease_in_out_expoease_in_elastic,ease_out_elastic,ease_in_out_elastic
For visual plots of each function, see easings.net.
Performance Notes
- SIMD versions leverage hardware vectorization for significant performance gains when processing multiple values simultaneously.
- Scalar versions are optimized for single-value operations.
- All implementations are branchless where possible for better performance.
Building the Demo
The included demo binary generates visual plots for all easing functions. To build
and run it, you will need a nightly Rust toolchain and enable the nightly and
demo features:
This will create PNG plots in the demo_plots/ directory, with subdirectories for
f32 and f32x4 variants.
Note: The demo feature is optional and includes the plotters dependency
for generating plots. It is not required for using the easing functions.
Running Benchmarks
To run performance benchmarks for all easing functions:
This will run benchmarks for all 180 functions (30 easing functions × 6 types:
f32, f64, f32x4, f32x8, f64x2, f64x4) and generate HTML reports in the
target/criterion/ directory, providing detailed performance comparisons.
License
This project is licensed under the MIT License.