Skip to main content

Module phase

Module phase 

Source
Expand description

Loader math — the pure phase functions behind the loading indicators.

These are the curves and constants the gpui viewport animates with (motion, bezel::loaders), kept pure so any surface animates the same loaders rather than inventing its own spinner. A loading indicator is a brand surface; two of them that disagree read as two products.

Everything is a pure function of a phase in 0..1, so a caller can drive it from a frame delta or from wall-clock elapsed time and get identical output.

Constants§

GRADIENT_SPIN_MS
Gradient matrix spinner wave period.
GSPIN_DIM
Opacity a gradient-spinner cell rests at between pulses.
GSPIN_ROW_TINTS
Per-row tints of the gradient matrix spinner — a “sunrise” gradient sampled at each row: cool blue at the top, through amber, to pink.
MATRIX_SIDE
Side length of the gradient spinner matrix.
MINI_RING
Clockwise ring position of each (row, col) cell of the 2×3 mini spinner, top-left first: (0,0) → (0,1) → (1,1) → (2,1) → (2,0) → (1,0). Every cell of a 2×3 grid is on the ring, so the brightness chases around it.
MINI_RING_LEN
Cells in the mini spinner’s ring.
ORBS
Orbs in the ORB_SEATS cluster.
ORB_BLOOM_MAX
ORB_BLOOM_MIN
Where a bloom ring starts and ends, as fractions of the box.
ORB_BLOOM_RINGS
Rings in flight at once in the bloom.
ORB_DRIFT
How far a cluster orb wanders from its seat, as a fraction of the box. Wide enough that neighbours overlap at one end of the walk and separate at the other.
ORB_GLOW_MAX
ORB_GLOW_MIN
Glow radius at rest and at full breath, as fractions of the box.
ORB_MAX_SIZE
ORB_MIN_OPACITY
An orb never goes out entirely — the cluster dims, it does not blink.
ORB_MIN_SIZE
A cluster orb’s diameter at its smallest and largest, as fractions of the box. The swing is the whole point: at the bottom an orb is nearly gone, so the count you perceive changes as they trade places. A fixed size would leave the silhouette constant and the thing would read as three dots dimming.
ORB_MS
Orb period. Slower than either spinner: these breathe rather than tick, and a tick at this size reads as impatience.
ORB_RING_DOT
ORB_RING_DOTS
Dots in the orb_ring_seat ring.
ORB_RING_RADIUS
The ring’s radius and its dot diameter, as fractions of the box.
ORB_SEATS
Where each cluster orb sits, as (x, y) fractions of the box — a triangle, so the group reads as one object and still fills a square slot.
PULSE_CELLS
Cells in the pulse wave loader.
PULSE_MIN_OPACITY
Pulse loader cells rest at this opacity between pulses.
PULSE_MIN_SCALE
…and at this scale.
PULSE_MS
Pulse loader period.
PULSE_STAGGER
Per-cell stagger, as a fraction of the pulse period (0.15s of 2.4s).

Functions§

gspin_cell_phase
The phase offset of a (row, col) cell in the 3×3 gradient spinner: the pulse enters at the bottom edge and converges toward the top-centre cell, so the wave reads as travelling upward.
gspin_opacity
Gradient-spin cell opacity for a local phase t (0..1 of the period), ported from the gradient-spin-pulse keyframes: full at the cycle start, easing down to dim by 45%, resting at dim until 92%, then rising back to full — the per-cell phase offset sweeps this pulse across the grid.
lerp
Linear interpolation.
orb_bloom_opacity
A bloom ring’s opacity: full as it leaves the centre, gone by the edge — squared, so it holds its brightness through the middle of the travel and then goes quickly, which is what keeps the ring from looking like a dissolving circle.
orb_bloom_radius
A bloom ring’s radius, as a fraction of the box: out from ORB_BLOOM_MIN to ORB_BLOOM_MAX once per period.
orb_converge_radius
The converge’s radius at phase: in to nothing, back out to the ring.
orb_drift
How far a cluster orb has drifted from its seat, as (dx, dy) fractions of the box — a small circle walked once per period.
orb_glow
One cluster orb’s glow radius, as a fraction of the box. In step with the opacity, because a glow that peaks off-beat reads as two lights rather than one breathing.
orb_opacity
One cluster orb’s opacity as it breathes: ORB_MIN_OPACITY → 1 → back.
orb_ring_seat
Where ring dot index sits on a circle of radius, as (x, y) fractions of the box. Twelve o’clock first, going clockwise.
orb_size
One cluster orb’s diameter, as a fraction of the box.
pulse_opacity
Pulse loader cell opacity for a phase: 0.08 → 1 → 0.08.
pulse_scale
Pulse loader cell scale for a phase: 0.9 → 1 → 0.9.
pulse_wave
Cosine pulse: 0 at phase 0, 1 at phase 0.5, back to 0 at phase 1.
staggered_phase
A cell’s phase, given the loader’s raw phase and the cell’s index.