Struct vek::transition::Transition

source ·
pub struct Transition<T, F, Progress = f32> {
    pub start: T,
    pub end: T,
    pub progress: Progress,
    pub progress_mapper: F,
}
Expand description

A convenience structure for storing a progression from one value to another.

Fields§

§start: T

The value when progress gets close to 0.

§end: T

The value when progress gets close to 1.

§progress: Progress

Expected to be between 0 and 1.

§progress_mapper: F

Functor that maps the current progress value to a LERP factor.

Implementations§

source§

impl<T, F, Progress> Transition<T, F, Progress>

source

pub fn with_mapper(start: T, end: T, progress_mapper: F) -> Selfwhere Progress: Zero,

Creates a new Transition from start and end values and progress_mapper, setting progress to zero.

source

pub fn with_mapper_and_progress( start: T, end: T, progress_mapper: F, progress: Progress ) -> Self

Creates a new Transition from start, end, progress_mapper and progress values.

source

pub fn into_range(self) -> Range<T>

Converts this into a Range, dropping the progress and progress_mapper values.

source§

impl<T, F, Progress> Transition<T, F, Progress>where F: ProgressMapper<Progress>,

source

pub fn into_current(self) -> Twhere T: Lerp<Progress, Output = T>, Progress: Clamp + Zero + One,

Gets the transition’s current state, clamping progress to [0;1].

source

pub fn into_current_unclamped(self) -> Twhere T: Lerp<Progress, Output = T>,

Gets the transition’s current state using the progress value as-is.

source

pub fn into_current_precise(self) -> Twhere T: Lerp<Progress, Output = T>, Progress: Clamp + Zero + One,

Gets the transition’s current state, clamping progress to [0;1].

source

pub fn into_current_unclamped_precise(self) -> Twhere T: Lerp<Progress, Output = T>,

Gets the transition’s current state using the progress value as-is.

source

pub fn current<'a>(&'a self) -> Twhere &'a T: Lerp<Progress, Output = T>, Progress: Copy + Clamp + Zero + One,

Gets the transition’s current state, clamping progress to [0;1].

source

pub fn current_unclamped<'a>(&'a self) -> Twhere &'a T: Lerp<Progress, Output = T>, Progress: Copy,

Gets the transition’s current state using the progress value as-is.

source

pub fn current_precise<'a>(&'a self) -> Twhere &'a T: Lerp<Progress, Output = T>, Progress: Copy + Clamp + Zero + One,

Gets the transition’s current state, clamping progress to [0;1].

source

pub fn current_unclamped_precise<'a>(&'a self) -> Twhere &'a T: Lerp<Progress, Output = T>, Progress: Copy,

Gets the transition’s current state using the progress value as-is.

source§

impl<T, Progress> Transition<T, IdentityProgressMapper, Progress>

source

pub fn new(start: T, end: T) -> Selfwhere Progress: Zero,

Creates a new LinearTransition from start and end values, setting progress to zero.

source

pub fn with_progress(start: T, end: T, progress: Progress) -> Self

Creates a new LinearTransition from start, end and progress values.

Trait Implementations§

source§

impl<T: Clone, F: Clone, Progress: Clone> Clone for Transition<T, F, Progress>

source§

fn clone(&self) -> Transition<T, F, Progress>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug, F: Debug, Progress: Debug> Debug for Transition<T, F, Progress>

source§

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

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

impl<T: Default, F: Default, Progress: Zero> Default for Transition<T, F, Progress>

source§

fn default() -> Self

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

impl<'de, T, F, Progress> Deserialize<'de> for Transition<T, F, Progress>where T: Deserialize<'de>, F: Deserialize<'de>, Progress: Deserialize<'de>,

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<T, F: Default, Progress: Zero> From<Range<T>> for Transition<T, F, Progress>

source§

fn from(r: Range<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Hash, F: Hash, Progress: Hash> Hash for Transition<T, F, Progress>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: PartialEq, F: PartialEq, Progress: PartialEq> PartialEq<Transition<T, F, Progress>> for Transition<T, F, Progress>

source§

fn eq(&self, other: &Transition<T, F, Progress>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, F, Progress> Serialize for Transition<T, F, Progress>where T: Serialize, F: Serialize, Progress: Serialize,

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<T: Copy, F: Copy, Progress: Copy> Copy for Transition<T, F, Progress>

source§

impl<T: Eq, F: Eq, Progress: Eq> Eq for Transition<T, F, Progress>

source§

impl<T, F, Progress> StructuralEq for Transition<T, F, Progress>

source§

impl<T, F, Progress> StructuralPartialEq for Transition<T, F, Progress>

Auto Trait Implementations§

§

impl<T, F, Progress> RefUnwindSafe for Transition<T, F, Progress>where F: RefUnwindSafe, Progress: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, F, Progress> Send for Transition<T, F, Progress>where F: Send, Progress: Send, T: Send,

§

impl<T, F, Progress> Sync for Transition<T, F, Progress>where F: Sync, Progress: Sync, T: Sync,

§

impl<T, F, Progress> Unpin for Transition<T, F, Progress>where F: Unpin, Progress: Unpin, T: Unpin,

§

impl<T, F, Progress> UnwindSafe for Transition<T, F, Progress>where F: UnwindSafe, Progress: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

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