Visualizations
376 / 500

376 · Astronomy

Baby Universe

Tune the universe's ingredients and watch the microwave sky respond.

A full-sky map of the cosmic microwave background, drawn on a Mollweide projection, synthesized from spherical harmonics with a stable Legendre recursion and a hand-written FFT along every ring. The angular power spectrum comes from the physics of the early photon-baryon fluid: the expansion history is integrated for your baryon density, dark matter density and curvature to get the sound horizon and the distance to last scattering, which set the acoustic peaks, while baryon loading, radiation driving and diffusion damping shape their heights. The sky is synthesized once as 17 band-limited maps, so any new spectrum is just a weighted sum of them and the same hot and cold spots stay put while their size and contrast follow the physics.

Try it. Drag the sliders or pick a preset universe: curvature resizes the spots, less dark matter makes them louder, more baryons lift the odd peaks. Hover the sky for a magnifier with the temperature in microkelvin. Drag across the spectrum to see only those scales on the map, click it to clear. R rolls a new sky.

  • Spherical harmonic synthesis
  • Mollweide projection
  • Band-split map recombination

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a cosmic microwave background sky generator with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and has a dark navy background.
- Write a function D(l) for the temperature power spectrum. A sum of a flat Sachs-Wolfe plateau and a damped cosine works: acoustic peaks spaced about 300 apart in l, the first near l = 220, fading with exp(-(l / 1300)^2).
- Synthesize a flat patch of sky first: fill a 256 x 256 grid of Fourier coefficients with Gaussian random numbers scaled by sqrt(C_l), where l is 2 pi times the wavenumber divided by the patch size in radians, and inverse transform it with a small FFT you write yourself.
- Color each temperature with a diverging blue to cream to red scale through ImageData, about plus or minus 300 microkelvin.

Once that works, make it beautiful:
- Upgrade to the whole sky: sum spherical harmonics up to l = 200 ring by ring, using the standard recursion for normalized associated Legendre functions and an FFT along each ring of constant latitude. Do the work over several animation frames so the page never freezes.
- Draw it on a Mollweide projection (inverse-map every pixel of an ellipse to latitude and longitude) with a faint graticule.
- Add sliders that stretch the peak spacing and change their heights, and redraw the map and a small plot of D(l) under it.
- Show the temperature in microkelvin under the mouse.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as computing the peak positions from a real sound horizon and distance, splitting the sky into bands so sliders update instantly, or adding a magnifier lens.
PreviousSpatial IndexesQuadtree, k-d tree, BVH and grid rebuilt every frame over thousands of moving points. NextRisograph PressA poster printed in CMYK or two riso inks, with a loupe that shows the rosettes.

Related visualizations

  • Cosmic WebAstronomy Noise grows into the filaments, voids and clusters of the universe.
  • Cosmic Light ConeAstronomy Our past light cone, horizons and galaxies in the expanding universe, drawn three ways.
  • Earth-Rotation SynthesisAstronomy Radio dishes ride the turning Earth to image a hidden galaxy, then CLEAN it.
  • WormholeAstronomy Fly through a traversable wormhole into another universe, with real light bending.
  • Sky MachinePhysics Drag the sun and watch real Rayleigh and Mie scattering paint the sky.
  • Dark Matter CurveAstronomy Switch off the dark halo and watch a spiral galaxy fly apart.
  • PlanetAstronomy A procedurally generated world with oceans, clouds and a glowing atmosphere.
  • Star TrailsAstronomy A long exposure builds over a mountain camp as the sky wheels around the celestial pole.
  • TwinkleAstronomy Turbulent air boils a star into speckles until adaptive optics snaps it sharp.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs