pub enum Curve {
Linear,
OutCubic,
OutBack,
InOutQuad,
InOutCubic,
Spring(Spring),
Bezier {
x1: f64,
y1: f64,
x2: f64,
y2: f64,
},
}Expand description
How a value travels from one end to the other.
Variants§
Linear
OutCubic
Fast start, soft landing. The default because it reads as responsive without looking mechanical.
OutBack
Overshoots slightly and settles back — for things appearing.
InOutQuad
Slow at both ends. For things that move rather than appear.
InOutCubic
Slow at both ends, more so: a longer wind-up and a longer settle around
a faster middle. The same journey Self::InOutQuad makes, read as
weight rather than as travel — for something crossing a screen rather
than moving between two slots, which is what the genie does.
Spring(Spring)
Bezier
Any curve at all, as the two control points of a cubic bezier from
(0,0) to (1,1) – the same four numbers CSS calls cubic-bezier and
every easing site on the internet hands out.
The named curves above are the ones worth having a name; this is so a feel nobody anticipated does not need a compositor release.
Implementations§
Source§impl Curve
impl Curve
Sourcepub fn at(self, t: f64) -> f64
pub fn at(self, t: f64) -> f64
The curve’s value for a normalised time in 0..=1.
May exceed 1 on the way — that is what overshoot is — so callers must not clamp the result, only the time.
Sourcepub fn all() -> [(&'static str, Self); 6]
pub fn all() -> [(&'static str, Self); 6]
Every curve, for tools that want to show them all.
This is the whole vocabulary Self::from_name knows, so it is also
what a script may write — and what the shipped lua/*.lua is checked
against by script::tests. Self::Bezier is deliberately not here:
it has no name, it is four numbers.