to_css_linear
Samples an easing function into a CSS linear() easing, so that any curve (a
Spring, a custom bounce) can be played by CSS transitions and the Web
Animations API, which do not take code.
Values are rounded to 4 decimals. More samples follow the curve more closely, in a longer string; 32 is smooth for most springs.
Import
Section titled “Import”Cargo feature animation (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
easing | &dyn Fn(f64) -> f64 | The easing function over 0.0..=1.0. |
samples | u32 | Number of points, evenly spaced in time, at least 2. |
Returns
Section titled “Returns”Option<String> — A linear(...) string, or None when samples is less than 2.
