Skip to main content

Module animation

Module animation 

Source
Expand description

动画系统 —— 原 mgui-animation crate,已合入 mgui-core

分层:

  • core(本模块): 纯逻辑的 AnimationController — 时间驱动、无时钟、 无副作用。app/runtime 提供 now_ms(winit 事件循环 / AboutToWait), 每帧调 tick(now_ms) 拿插值,写进 Signal 后由响应式系统触发 rebuild。
  • runtime/app: 持有 controller,在 AboutToWait 里 tick → Signal::set → request_redraw(见 showcase 的自动旋转演示)。

设计取舍:

  • 不引入独立 Ticker trait — winit 的 redraw 循环就是天然的 ticker, controller 的 is_animating() 决定是否继续请求下一帧。
  • 状态机不依赖外部时钟源 — forward(now_ms) 记录起始时刻, tick(now_ms) 按时间差推进,暂停/恢复语义清晰。
  • 曲线纯函数 — Curve::transform(t) 可独立单测。

Structs§

AnimationController
时间驱动的动画控制器

Enums§

AnimationStatus
动画状态
Curve
缓动曲线(输入输出均为 0..1)
Repeat
重复模式
TickOutcome
tick() 的推进结果

Functions§

tick_animation
对一个 AnimationController 调 tick(now_ms), 若产生 Value(t) 则把 t 传给 on_value 闭包(通常写 Signal)。