This is a Rust port of gre/bezier-easing.
Bezier easing provides a way to create custom easing functions (ease-in, ease-out, ease-in-out...) for use in animations.
By providing the coordinates of the bezier curve's control points, you can create your own easing functions that follow the curve you've defined.
crates/bezier-easing: the published Rust library.examples/wasm-demo: an HTML canvas demo powered by the Rust library compiled to WebAssembly.
[dependencies]
bezier_easing = "0.3"use bezier_easing::bezier_easing;
let ease = bezier_easing(0.0_f64, 0.0, 1.0, 0.5).unwrap();
assert_eq!(ease.sample(0.0), 0.0);
assert!((ease.sample(0.5) - 0.3125).abs() < 0.000001);
assert_eq!(ease.sample(1.0), 1.0);The default floating point type is f64. Use suffixed arguments to create an f32 easing function:
use bezier_easing::bezier_easing;
let ease = bezier_easing(0.0_f32, 0.0, 1.0, 0.5).unwrap();
assert!((ease.sample(0.5) - 0.3125).abs() < 0.000001);Online demo: https://hlhr202.github.io/bezier-easing-rs/
wasm-pack build --target web --out-dir pkg examples/wasm-demo
npx serve examples/wasm-demoOpen the local URL printed by serve to view the canvas animation.
Run the release checks before publishing the library crate:
cargo fmt --check
cargo clippy -p bezier_easing --all-targets --all-features -- -D warnings
cargo test -p bezier_easing --all-features
cargo llvm-cov -p bezier_easing --all-features --fail-under-lines 90
cargo package -p bezier_easing
cargo publish -p bezier_easing --dry-runPublish only after the dry run succeeds:
cargo publish -p bezier_easingMIT