Skip to main content

Curve

Enum Curve 

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

Fields

§x1: f64
§y1: f64
§x2: f64
§y2: f64

Implementations§

Source§

impl Curve

Source

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.

Source

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.

Source

pub fn from_name(name: &str) -> Option<Self>

Look a curve up by the name a script or a settings file would use.

Source

pub fn name(self) -> &'static str

What to call this curve.

Trait Implementations§

Source§

impl Clone for Curve

Source§

fn clone(&self) -> Curve

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 Curve

Source§

impl Debug for Curve

Source§

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

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

impl Default for Curve

Source§

fn default() -> Curve

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Curve

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Curve

Auto Trait Implementations§

§

impl Freeze for Curve

§

impl RefUnwindSafe for Curve

§

impl Send for Curve

§

impl Sync for Curve

§

impl Unpin for Curve

§

impl UnsafeUnpin for Curve

§

impl UnwindSafe for Curve

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.