Visualizations
297 / 500

297 · Physics

Blacksmith's Forge

Heat, hammer and quench a steel bar whose glow and temper colors come from physics.

The bar is 140 cells solving the heat equation: conduction scaled by each cell's hammered cross section, heat from the coals, Newton cooling and Stefan-Boltzmann radiation in air, and a fierce heat transfer coefficient under water. Its glow is Planck's law integrated through the CIE 1931 color matching functions, with a logarithmic exposure like an eye adapting to a dark smithy. On bright steel an oxide film grows with Arrhenius kinetics, and its color is thin-film interference from the Airy formula with complex refractive indices, so when the tip is quenched and lifted out, heat flowing back from the shank runs straw, bronze, purple and blue toward the tip while a loupe follows the colors.

Try it. Drag the bar between the fire, the anvil, the quench tub and the air. Click the bar on the anvil to hammer it (hot steel thins and throws scale, cold steel just rings). Hold B or press on the fire to work the bellows, press F, A, Q or T to move the bar, Space to strike, and R for a fresh bar.

  • Heat equation
  • Planck's law to sRGB
  • Thin-film interference
  • Bloom pyramid

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 blacksmith's forge with JavaScript and the HTML canvas element, where a steel bar heats up, glows with physically computed colors, and cools. 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), with a dark background, a glowing coal bed on the left and an anvil on the right.
- Model the bar as about 100 cells along its length, each with a temperature in Celsius. Every frame, run a few small steps of the 1D heat equation (each cell moves toward the average of its neighbors), add heat to cells inside the fire, and remove heat everywhere else in proportion to temperature.
- Write a blackbody color function: integrate Planck's law times the CIE 1931 color matching functions (use the Wyman, Sloan and Shirley Gaussian fit) from 380 to 780 nm, convert XYZ to sRGB, and set brightness from the logarithm of the luminance so glow appears around 500 C and turns yellow-white past 1200 C. Precompute it into a table.
- Draw the bar as thin vertical slices colored by that table, and let me drag it in and out of the fire.

Once that works, make it beautiful:
- Add bloom by drawing the glowing parts into a small offscreen canvas, shrinking it a few times and adding the copies back with globalCompositeOperation = "lighter".
- Add a water tub: cells under water cool very fast and throw off steam puffs.
- Draw flickering coals and drifting embers, and let firelight tint the scene.

Explain the physics 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 hammering that thins the hot steel, temper colors from thin-film interference on an oxide layer, or a live graph of temperature along the bar.
PreviousAntikythera MechanismThe 2,000-year-old Greek computer, every gear meshing, scrubbing across centuries. NextInk in WaterA real fluid solver swirls colored dye like ink in water.

Related visualizations

  • Discharge TubesPhysics Glowing gas tubes whose colors are computed from their real spectral lines.
  • Soap FilmFluids A draining soap film swirls with true thin-film colors until it turns black and pops.
  • BonfireFluids A campfire whose flames are a fluid simulation colored by blackbody physics.
  • Damascus SteelGenerative art Forge pattern-welded steel as a chain of exact maps, then grind and etch the blade.
  • FoamEmergence Soap foam coarsens under von Neumann's exact law, with live T1 swaps and vanishing cells.
  • DendritesSimulation Supercooled melt freezes into branching dendrites, with latent heat glowing between arms.
  • Soap Film Steiner TreesPhysics Soap films between pegs relax into Steiner trees, meeting at 120 degrees.
  • Chromaticity LabMath Draw any light's spectrum and watch it land on the CIE 1931 horseshoe.
  • Melting CrystalSimulation Nearly 2,000 atoms freeze into crystal grains, melt and boil from one pairwise force.

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

← More from Emergent Mind Labs