Animator

Struct Animator 

Source
pub struct Animator { /* private fields */ }
Expand description

Manages animations. Assumes that you always pass it with Anim objects with the same types of Tracks. For example, if track 0 represents represents a color Vec4, and track 1 represents a Float value, then make sure to use that consistently throughout the lifetime of an Animator.

TODO(JP): Look into enforcing this through the type system, instead of at runtime.

Also note that the Animator always contains the “source of truth” for the values it manages, so whenever necessary you should copy the values kept here to the actual “draw objects”.

Implementations§

Source§

impl Animator

Source

pub fn play_anim(&mut self, cx: &mut Cx, anim: Anim)

Play an animation. If an animation is already playing, it’s either cut off, or remains playing with the new animation queued up, if Anim::chain is set in the new animation. If there was already another animation queued up, then it’s kicked from the queue.

Source

pub fn draw(&mut self, cx: &mut Cx, anim_default: Anim)

Process animations from a “draw” function. This must be called before reading any values.

The anim_default will initialze the Animator if it’s currently uninitialized.

Source

pub fn handle(&mut self, cx: &mut Cx, event: &Event) -> bool

Convenient function for only calling Animator::run_animator if the event is an Event::NextFrame. Returns true if we processed the animation so you can update your “draw objects”.

Source

pub fn get_float(&self, track_index: usize) -> f32

Get the value of the given track as a float. Be sure to call this only if the given track is indeed always a float in the Anims you pass into this Animator. TODO(JP): Instead of having multiple functions here, perhaps we can use [Into?

Source

pub fn get_vec2(&self, track_index: usize) -> Vec2

Get the value of the given track as a Vec2. Be sure to call this only if the given track is indeed always a Vec2 in the Anims you pass into this Animator. TODO(JP): Instead of having multiple functions here, perhaps we can use [Into?

Source

pub fn get_vec3(&self, track_index: usize) -> Vec3

Get the value of the given track as a Vec3. Be sure to call this only if the given track is indeed always a Vec3 in the Anims you pass into this Animator. TODO(JP): Instead of having multiple functions here, perhaps we can use [Into?

Source

pub fn get_vec4(&self, track_index: usize) -> Vec4

Get the value of the given track as a Vec4. Be sure to call this only if the given track is indeed always a Vec4 in the Anims you pass into this Animator. TODO(JP): Instead of having multiple functions here, perhaps we can use [Into?

Trait Implementations§

Source§

impl Debug for Animator

Source§

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

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

impl Default for Animator

Source§

fn default() -> Animator

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

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,