Skip to main content

AnimationState

Struct AnimationState 

Source
pub struct AnimationState { /* private fields */ }

Implementations§

Source§

impl AnimationState

Source

pub fn new(frames: Vec<(RgbaImage, Duration)>, loop_count: Option<u32>) -> Self

Build from decoded frames + loop count. Starts playing at frame 0.

Source

pub fn current_frame(&self) -> &RgbaImage

Source

pub fn frame_index(&self) -> usize

Source

pub fn frame_count(&self) -> usize

Source

pub fn is_playing(&self) -> bool

Source

pub fn is_finished(&self) -> bool

Source

pub fn advance(&mut self, dt: Duration) -> bool

Accumulate dt, flipping to later frames as each delay elapses (a large dt may cross several frames). On wrapping past the last frame, count a loop; if a finite loop count is then reached, finish and rest on the last frame. No-op when paused, finished, or single-frame. Returns whether the displayed frame changed.

Source

pub fn next_deadline(&self) -> Option<Duration>

Time until the next frame flip, or None when paused/finished/single-frame.

Source

pub fn toggle_pause(&mut self)

Play/pause toggle. Reviving a finished animation restarts it (so the play key brings a stopped GIF back to life).

Source

pub fn step(&mut self, delta: i32)

Pause and move ±1 frame (wrapping). Clears the finished state.

Source

pub fn restart(&mut self)

Restart from frame 0, playing, loop counter reset.

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.