Skip to main content

Animator

Struct Animator 

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

Eases a displayed Scene toward a target Scene, filling Frames.

Implementations§

Source§

impl Animator

Source

pub fn new() -> Self

Source

pub fn set_target( &mut self, target: Scene, now_ms: f64, dur_ms: f32, easing: Easing, tween: bool, )

Point the animator at a new target. Tweens from the currently-displayed scene when tween is on, dur_ms > 0, and there’s something to move from; otherwise snaps. (Same contract as before the index rewrite.)

Source

pub fn tick_into(&mut self, now_ms: f64, out: &mut Frame)

Advance to now_ms and fill out. Commits the target when the transition completes.

Source

pub fn tick_positioned_into( &mut self, now_ms: f64, pos: &[Option<[f32; 2]>], out: &mut Frame, )

Advance, then override node positions from pos (dense, indexed by NodeIndex; None = animator keeps its interpolated position) before filling out.

This is the boundary between the two things that want to move a node: the simulation owns position, the animator owns appearance. The override is written into self.displayed IN PLACE — not into a throwaway copy — so displayed stays truthful about what’s on screen; the next set_target snapshots displayed as the transition’s from, and a stale snapshot makes any node that later leaves the simulation teleport (the Slice A bug; its regression test lives below).

Caller contract (unchanged from Slice A): pos must cover every node the simulation owns, on every call — an owned-but-omitted index falls back to plain position-tweening for that call, which reads as the node fighting the simulation.

Source

pub fn target_positions(&self) -> impl Iterator<Item = [f32; 2]> + '_

Positions of the current target scene’s nodes (post-transition).

Source

pub fn target_position(&self, ix: NodeIndex) -> Option<[f32; 2]>

Target position of one node (post-transition), if present.

Trait Implementations§

Source§

impl Default for Animator

Source§

fn default() -> Self

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.