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.
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.