Skip to main content

Module dynamics

Module dynamics 

Source
Expand description

Water-droplet motion physics shared by every travelling liquid lens.

The reference lens (example/iphone17_records, example/target/tab-swipe) deforms with its motion, not with its position: cruising speed stretches the bubble along the travel axis, acceleration compresses it against the push, deceleration releases that compression past neutral and swells the leading edge — and whatever one axis does, the orthogonal axis does in reverse so the droplet keeps its area (an incompressible bubble).

LiquidDynamics is the one frame integrator implementing that law. Widgets feed it the lens ride position once per drawn frame (from inside their glass_effect_with closure) and map the returned LiquidPose onto the morph uniforms. Time comes from the runtime’s animation clock — never wall time — so poses stay exact under robot keyframe captures and on wasm.

Every channel relaxes exponentially, so none of them ever reaches neutral on its own. Once travel, strain and swell are all within a fraction of a device pixel of rest, the integrator snaps them to exactly LiquidPose::default and stops producing new poses, so a settled lens costs nothing per frame. Until then a pose changes with the clock alone, so each update that returns one away from rest asks for the next frame’s re-record of the node being drawn (cranpose_ui::request_current_draw_redraw): a lens keeps relaxing after its input stops, and only for as long as it has to.

Structs§

LiquidDynamics
Per-lens frame integrator. Interior-mutable so per-frame draw closures (plain Fn) can advance it without a RefCell dance.
LiquidPose
Motion-derived deformation of a liquid lens for one frame.

Constants§

BULGE_MAX
STRETCH_MAX
STRETCH_MIN
The droplet never deforms past these bounds, however violent the fling. Public so hosting nodes can budget layout headroom for the extremes.

Functions§

rememberLiquidDynamics
Remember one LiquidDynamics for the calling composition site.