Expand description
Confetti particle overlay โ a reusable win-celebration burst effect.
This is a self-contained simulation + paint helper, not a [Widget]: it has
no layout, bounds, or event handling. It sits alongside crate::animation
(the Tween interpolator) and crate::timestep (the fixed-step scheduler)
as one of the animation/simulation primitives the framework offers to apps.
A caller creates a ConfettiSystem with ConfettiSystem::burst, then
each frame:
- advances the physics with
ConfettiSystem::tick, passing the wall-clock delta since the previous frame in seconds, and - draws it with
ConfettiSystem::paint.
tick returns false once every particle has expired, so the caller can
drop the system and stop drawing. While particles are alive, tick calls
crate::animation::request_draw so the host keeps producing frames without
any user input โ the same pattern crate::animation::Tween::tick uses.
Time is taken entirely from the caller (dt_seconds); the module reads no
clock and pulls in no OS randomness, so it is wasm32-clean. Randomness
comes from a small deterministic splitmix64 PRNG seeded by the caller, which
makes a burst fully reproducible from its seed.
All coordinates follow the crate-wide Y-up, first-quadrant convention: positive Y is up, so gravity pulls particles toward smaller Y and the initial upward spread uses positive vertical velocity.
Structsยง
- Confetti
System - An owned collection of confetti particles that animate together.