Skip to main content

ValueBezier

Struct ValueBezier 

Source
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: f32

The 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: f32

The second control point’s value minus the next keyframe’s value.

Implementations§

Source§

impl ValueBezier

Source

pub const fn unweighted(leave: f32, arrive: f32) -> Self

Creates a curve with control points at one third and two thirds of the segment.

Source

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.

Source

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).

Source

pub fn weights(self) -> Option<(f32, f32)>

The time coordinates, or None for the unweighted form.

Source

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.

Source

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.

Source

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.

Source

pub fn slope_between(self, from: f64, to: f64, progress: f64) -> f64

Self::slope between ends of any size.

Source

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.

Source

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.

Source

pub fn reversed(self) -> Self

The curve of the same segment played backwards, from its right keyframe to its left.

Source

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.

Source

pub fn rebased_between(self, ends: (f64, f64), new_ends: (f64, f64)) -> Self

Self::rebased between ends of any size.

Source

pub fn range(self, from: f32, to: f32) -> [f64; 2]

The least and greatest value over the segment from from to to.

Source

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.

Source

pub fn end_slope_between(self, from: f64, to: f64, at_end: bool) -> f64

Self::end_slope between ends of any size.

Source

pub fn turns_between(self, from: f64, to: f64) -> [Option<f64>; 2]

The linear progresses strictly inside 0..1 at which the value between from and to stops rising or falling, in no order.

Trait Implementations§

Source§

impl Clone for ValueBezier

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ValueBezier

Source§

impl Debug for ValueBezier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ValueBezier

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ValueBezier

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ValueBezier

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ValueBezier

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.