Raxol.Animation.Clock (Raxol v2.6.0)

View Source

Time source for the animation system.

By default this is the wall clock (System.system_time(:millisecond)), so live rendering is unaffected. Offline renderers (the video render target) can freeze/1 it to a fixed virtual time, making every captured frame deterministic regardless of how long rasterization actually takes.

Both the per-frame "now" (Raxol.Animation.AnimationProcessor) and an animation's start_time (Raxol.Animation.Lifecycle) read through here, so a frozen clock keeps interpolation coherent across the two.

The freeze is global to the BEAM node. Freeze only while driving a dedicated, offline render; do not freeze while serving live animated UIs on the same node.

Summary

Functions

Pin animation time to ms until unfreeze/0.

Whether the clock is currently frozen.

Current animation time in milliseconds (frozen value if set, else wall clock).

Resume wall-clock time.

Functions

freeze(ms)

@spec freeze(integer()) :: :ok

Pin animation time to ms until unfreeze/0.

frozen?()

@spec frozen?() :: boolean()

Whether the clock is currently frozen.

now()

@spec now() :: integer()

Current animation time in milliseconds (frozen value if set, else wall clock).

unfreeze()

@spec unfreeze() :: :ok

Resume wall-clock time.