pub struct Animator { /* private fields */ }Expand description
Eases a displayed Scene toward a target Scene, filling Frames.
Implementations§
Source§impl Animator
impl Animator
pub fn new() -> Self
Sourcepub fn set_target(
&mut self,
target: Scene,
now_ms: f64,
dur_ms: f32,
easing: Easing,
tween: bool,
)
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.)
Sourcepub fn tick_into(&mut self, now_ms: f64, out: &mut Frame)
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.
Sourcepub fn tick_positioned_into(
&mut self,
now_ms: f64,
pos: &[Option<[f32; 2]>],
out: &mut Frame,
)
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.
Sourcepub fn target_positions(&self) -> impl Iterator<Item = [f32; 2]> + '_
pub fn target_positions(&self) -> impl Iterator<Item = [f32; 2]> + '_
Positions of the current target scene’s nodes (post-transition).