Backgrounds

Cathode

A cathode-ray tube slowed down until you can watch it work: the beam paints a test card line by line, and the phosphor it leaves behind fades until the next pass comes round.

Install

bun add ogl

Then copy 2 files into your project:

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

Props

PropTypeDefaultDescription
signal"testcard" | "bars" | "grid" | "snow""testcard"What the beam is painting. Snow is redrawn behind the beam line by line, the way a set with nothing on the line actually refreshed it. Colour bars carry their own hue; every other signal borrows the phosphor's.
scanRatenumber0.3Frames the beam completes per second. A real set runs at fifty or sixty, which is exactly why nobody sees the raster. At zero the beam parks and the picture keeps fading behind it.
persistencenumber0.55How long the phosphor holds after the beam has passed. Low leaves a bright band trailing the beam over a dark face; high holds the whole picture. Computed from how long ago the beam crossed each pixel rather than by keeping the previous frame, so it costs one exponential and no render target.
scanlineDensitynumber3Height of one raster line, which is also one pass of the beam. Below about two pixels the line pattern is past Nyquist, so it fades out instead of aliasing into moiré that moves when the window does.
scanlineDepthnumber0.4How dark the gaps between raster lines are. The aperture grille rides at a third of this — a shadow mask you can resolve has stopped being a background.
curvaturenumber0.18Barrel distortion of the tube face. The raster bends with it, and the glass edge is a soft falloff rather than a clip, because a hard rim aliases along its whole length.
bloomnumber0.6Halation around the beam and the bright parts of the picture. Four taps of the analytic picture rather than a blur pass.
rollSpeednumber0.2Speed of the hum bar, a faint band of mains interference rolling up the glass.
chromaOffsetnumber0.8Convergence error between the colour guns. Held in pixels, so the fringe reads the same on a strip as on a full page.
phosphorColorstring (hex)"#7ef0c0"The phosphor. Every signal is drawn in it except the colour bars.
backgroundColorstring (hex)"#050607"The dead glass outside the picture.

What It Demonstrates

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