Backgrounds

Cathode

A cathode-ray tube showing nothing worth watching: a beam that turns around at each edge, phosphor that holds after it has passed, and a hum bar rolling up the glass.

Install

bun add ogl

Then copy 2 files into your project:

  • components/registry/cathode/cathode.tsx
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
signal"sweep" | "bars" | "snow" | "grid""sweep"What the tube is showing. Sweep is a single beam that reverses at each edge rather than jumping back — a beam that wrapped would read as a dropped frame, one that turns around reads as a mechanism. The rest are the test patterns a set falls back to when there is nothing on the line.
sweepSpeednumber0.5Speed of the beam across the face. At zero it parks and the phosphor settles, which is the clearest way to see what persistence is actually drawing.
scanlineDensitynumber2.2Pixels per scanline. Below about two the grille is past Nyquist, and rather than aliasing into a pattern that moves when the window does, the modulation fades out — a small canvas loses its scanlines instead of gaining moiré.
scanlineDepthnumber0.35How hard the scanlines and the aperture grille cut into the image. The grille rides at a third of this — a shadow mask you can actually resolve is a shadow mask that has stopped being a background.
curvaturenumber0.18Barrel distortion of the tube face. The glass edge is a soft falloff rather than a clip, because a hard rim aliases along its whole length and the rim is the one place the eye is guaranteed to go.
bloomnumber0.5Halation around bright areas. Four analytic taps of the signal rather than a blur pass — the signal has a closed form in every mode, so a glow costs arithmetic instead of a second render target.
persistencenumber0.4How long the phosphor holds after the beam has passed. Computed as an exponential in the distance already swept rather than by keeping the previous frame — which is what phosphor decay is, and it avoids the float render target that is the one thing the loop verifier cannot see through.
rollSpeednumber0.25Speed of the hum bar rolling up the frame. It carries its own decay tail, so persistence still means something on a signal that never moves.
chromaOffsetnumber0.6Convergence error between the colour guns. Held in pixels and converted through the face width, so the fringe reads the same on a strip as on a full page.
phosphorColorstring (hex)"#7ef0c0"The phosphor. Every signal borrows it except the colour bars, which carry their own hue — that is the whole point of a test card.
backgroundColorstring (hex)"#050607"The dead glass outside the picture.

What It Demonstrates

Alternate (yoyo)
A loop that plays forward then reverses each iteration, instead of jumping back to the start.
Loop
An animation that repeats, a set number of times or infinitely.
Idle animation
Subtle motion that plays while an element is just sitting there, waiting to be interacted with.
Compositing
Letting the GPU move or fade an element on its own layer without redoing layout or paint.

Related Components

Appears In