pub struct ValueBezier {
pub x1: Option<f32>,
pub leave: f32,
pub x2: Option<f32>,
pub arrive: f32,
}Expand description
A cubic Bezier in (time, value) between two keys of a number.
The control points are leave above this key’s value and arrive above the next key’s, at
x1 and x2 of the segment’s length. Without x1 and x2 they sit at one third and two
thirds, and the segment is a cubic Hermite curve.
Fields§
§x1: Option<f32>Time of the first control point as a fraction of the segment. Given with x2 or not at
all; the pair is any for which the curve never runs backwards in time.
leave: f32The first control point’s value minus this keyframe’s value.
x2: Option<f32>Time of the second control point as a fraction of the segment. Given with x1 or not at
all.
arrive: f32The second control point’s value minus the next keyframe’s value.
Implementations§
Source§impl ValueBezier
impl ValueBezier
Sourcepub const fn unweighted(leave: f32, arrive: f32) -> Self
pub const fn unweighted(leave: f32, arrive: f32) -> Self
Creates a curve with control points at one third and two thirds of the segment.
Sourcepub const fn weighted(x1: f32, leave: f32, x2: f32, arrive: f32) -> Self
pub const fn weighted(x1: f32, leave: f32, x2: f32, arrive: f32) -> Self
Creates a curve with control points at x1 and x2 of the segment.
Sourcepub fn is_valid(self) -> bool
pub fn is_valid(self) -> bool
Whether the offsets are finite, and the time coordinates are given together and never
run backwards (time_handles_valid).
Sourcepub fn weights(self) -> Option<(f32, f32)>
pub fn weights(self) -> Option<(f32, f32)>
The time coordinates, or None for the unweighted form.
Sourcepub fn value(self, from: f32, to: f32, progress: f64) -> f64
pub fn value(self, from: f32, to: f32, progress: f64) -> f64
The value at progress of the segment from from to to: from at 0 and before,
to at 1 and after. Between them it may leave the range of the two.
Uses only the operations of CubicBezier::apply, so every platform gets the same bits.
Sourcepub fn value_between(self, from: f64, to: f64, progress: f64) -> f64
pub fn value_between(self, from: f64, to: f64, progress: f64) -> f64
Self::value between ends of any size, such as times in ticks: with u the curve’s
parameter at progress and a, b, c its polynomial, from + ((a u + b) u + c) u
in that order of operations.
Sourcepub fn slope(self, from: f32, to: f32, progress: f64) -> f64
pub fn slope(self, from: f32, to: f32, progress: f64) -> f64
The slope at progress (clamped to 0..=1), in value per segment length. Always
finite: a vertical tangent gives the largest finite f64 with the slope’s sign.
Sourcepub fn slope_between(self, from: f64, to: f64, progress: f64) -> f64
pub fn slope_between(self, from: f64, to: f64, progress: f64) -> f64
Self::slope between ends of any size.
Sourcepub fn between(
self,
from: f32,
to: f32,
start: f64,
end: f64,
) -> (f32, f32, Self)
pub fn between( self, from: f32, to: f32, start: f64, end: f64, ) -> (f32, f32, Self)
The part of the segment from from to to between linear progress start and end:
the values at its two ends (Self::value rounded to f32) and the curve between
them. An unweighted curve gives an unweighted part.
Uses only the operations of CubicBezier::apply, so every platform gets the same bits.
Sourcepub fn part_between(
self,
ends: (f64, f64),
span: (f64, f64),
part_ends: (f64, f64),
) -> Self
pub fn part_between( self, ends: (f64, f64), span: (f64, f64), part_ends: (f64, f64), ) -> Self
The curve of the part of the segment between ends from linear progress span.0 to
span.1, for a segment between part_ends: the values a keyframe at each end of the
part holds. The part’s two inner control points stay where they are.
Sourcepub fn reversed(self) -> Self
pub fn reversed(self) -> Self
The curve of the same segment played backwards, from its right keyframe to its left.
Sourcepub fn rebased(self, from: f32, to: f32, new_from: f32, new_to: f32) -> Self
pub fn rebased(self, from: f32, to: f32, new_from: f32, new_to: f32) -> Self
The same curve between other end values: its control points stay where they are while
the segment’s ends move from from, to to new_from, new_to.
Sourcepub fn rebased_between(self, ends: (f64, f64), new_ends: (f64, f64)) -> Self
pub fn rebased_between(self, ends: (f64, f64), new_ends: (f64, f64)) -> Self
Self::rebased between ends of any size.
Sourcepub fn range(self, from: f32, to: f32) -> [f64; 2]
pub fn range(self, from: f32, to: f32) -> [f64; 2]
The least and greatest value over the segment from from to to.
Sourcepub fn end_slope(self, from: f32, to: f32, at_end: bool) -> f64
pub fn end_slope(self, from: f32, to: f32, at_end: bool) -> f64
The slope where the segment from from to to starts (at_end false) or ends, in value
per segment length: that of the control polygon’s first leg from that end that has a
time extent, the chord’s when none has.
Sourcepub fn end_slope_between(self, from: f64, to: f64, at_end: bool) -> f64
pub fn end_slope_between(self, from: f64, to: f64, at_end: bool) -> f64
Self::end_slope between ends of any size.