pub struct CubicBezier {
pub x1: f32,
pub y1: f32,
pub x2: f32,
pub y2: f32,
}Expand description
A CSS cubic-bezier(x1, y1, x2, y2) timing curve.
x1 and x2 lie in 0..=1, which keeps the curve a function of its input. y1 and y2
are unbounded, so a curve may overshoot.
Fields§
§x1: f32Horizontal coordinate of the first control point, in 0..=1.
y1: f32Vertical coordinate of the first control point.
x2: f32Horizontal coordinate of the second control point, in 0..=1.
y2: f32Vertical coordinate of the second control point.
Implementations§
Source§impl CubicBezier
impl CubicBezier
Sourcepub const fn new(x1: f32, y1: f32, x2: f32, y2: f32) -> Self
pub const fn new(x1: f32, y1: f32, x2: f32, y2: f32) -> Self
Creates a curve from its two inner control points.
Sourcepub fn apply(self, progress: f64) -> f64
pub fn apply(self, progress: f64) -> f64
The curve’s output at linear progress, which is clamped to 0..=1.
0 maps exactly to 0 and 1 to 1. Between them the output may leave 0..=1 when y1 or
y2 does.
Sourcepub fn between(self, from: f64, to: f64) -> Option<Self>
pub fn between(self, from: f64, to: f64) -> Option<Self>
The part of the curve between linear progress from and to, rescaled to the unit
square, so that it shows the same output over that part of a segment. None when the
output is equal at both ends (or the part is empty), which no rescaled curve can show.
Uses only the operations of Self::apply, so every platform gets the same bits.