pub struct Tween { /* private fields */ }Expand description
基于绝对时间戳(cx.now_ms())的单值补间器(no_std、零分配、Copy)。
存放在 View 状态中驱动任意自定义数值动画(角度、进度、偏移、颜色混合比等)。
渲染期以 value(cx.now_ms()) 采样,若 is_running(...) 则调用 cx.request_frame() 请求下一帧。
Implementations§
Source§impl Tween
impl Tween
Sourcepub const fn with_easing(self, easing: Easing) -> Self
pub const fn with_easing(self, easing: Easing) -> Self
设置缓动曲线。
Sourcepub const fn with_duration(self, duration_ms: u16) -> Self
pub const fn with_duration(self, duration_ms: u16) -> Self
设置补间时长(毫秒)。
Sourcepub const fn with_delay(self, delay_ms: u16) -> Self
pub const fn with_delay(self, delay_ms: u16) -> Self
设置启动延迟(毫秒)。
Sourcepub fn animate_to(&mut self, now_ms: u32, to: i32)
pub fn animate_to(&mut self, now_ms: u32, to: i32)
从当前采样值平滑过渡到新目标 to(打断进行中的补间时保持连续)。
Sourcepub fn progress_256(&self, now_ms: u32) -> i32
pub fn progress_256(&self, now_ms: u32) -> i32
已缓动的归一化进度(0..=256,过冲曲线可短暂超出)。
Sourcepub fn is_running(&self, now_ms: u32) -> bool
pub fn is_running(&self, now_ms: u32) -> bool
补间是否仍在进行中(含延迟段)。
Trait Implementations§
impl Copy for Tween
impl Eq for Tween
impl StructuralPartialEq for Tween
Auto Trait Implementations§
impl Forget for Tween
impl Freeze for Tween
impl Move for Tween
impl RefUnwindSafe for Tween
impl Send for Tween
impl Sync for Tween
impl Unpin for Tween
impl UnsafeUnpin for Tween
impl UnwindSafe for Tween
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
当
condition 为 true 时执行闭包修饰自身,否则原样返回。Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Self
fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
根据
condition 在两个修饰分支之间二选一。Source§fn when_some<O>(
self,
option: Option<O>,
then: impl FnOnce(Self, O) -> Self,
) -> Self
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
当
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。