pub struct Ease {
pub x1: f32,
pub y1: f32,
pub x2: f32,
pub y2: f32,
}Expand description
The one easing curve every surface moves on, as CSS’s cubic-bezier(x1, y1, x2, y2) with the endpoints pinned at (0, 0) and (1, 1).
Both y control points must stay inside 0.0..=1.0. That is what keeps
the curve monotone — an envelope that overshoots and comes back would make a
panel’s alpha rise past its target and fall again. Both x control points
must stay inside 0.0..=1.0 too, which is what makes x(t) invertible.
Fields§
§x1: f32First control point, time axis.
y1: f32First control point, progress axis.
x2: f32Second control point, time axis.
y2: f32Second control point, progress axis.
Implementations§
Source§impl Ease
impl Ease
Sourcepub fn at(self, t: f32) -> f32
pub fn at(self, t: f32) -> f32
Progress at normalised time t: 0.0 at t <= 0, 1.0 at t >= 1, and
the curve’s height in between.
Solves x(s) = t by bisection on the curve parameter s — a fixed 40
halvings in f64, which puts s well inside an f32 step of the root
and allocates nothing.
Monotone in t to the last bit, by construction. The height is read
at the bisection’s lower bound, which never decreases as t grows (every
comparison t passes, a larger t passes too), and it is computed in
f64 and rounded once — an f32 evaluation of the height wobbles by an
ulp near the top of a flat ease-out, which is a panel’s alpha stepping
back down on its last frames.