pub fn frame_clock(tick: impl FnMut(Duration) + 'static) -> impl PieceExpand description
A frame clock (§8.4): an invisible, zero-size piece that calls tick every animation frame with
the wall-clock delta since the previous frame, for as long as it is mounted. Drop it into the
tree (e.g. behind a canvas in a zstack) to drive a game loop or self-driven animation: the
tick mutates state Signals, and a canvas reading them re-records that frame.
Shares day::frame’s per-window native display scheduler (docs/frames.md); Day has no
timer fallback. Requests stop when the last consumer unmounts. This legacy piece retains
a first delta of 1/60 s and a <=100 ms clamp; the general frame API exposes raw elapsed time
and pause/resume handles. Inert on the mock backend.
ⓘ
zstack((
canvas(move |d, sz| draw(d, sz, state)).grow(),
frame_clock(move |dt| step(dt, state)),
))