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_SEATScluster. - 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_seatring. - 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 thegradient-spin-pulsekeyframes: full at the cycle start, easing down todimby 45%, resting atdimuntil 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_MINtoORB_BLOOM_MAXonce 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
indexsits on a circle ofradius, 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.