Visualizations
162 / 500

162 · Generative art

Damascus Steel

Forge pattern-welded steel as a chain of exact maps, then grind and etch the blade.

The billet starts as 13 alternating layers of bright nickel steel and dark carbon steel, so the colour of any point is just the parity of floor(13 * w), where w is its height in the original stack. Each forging step (fold, twist the bar as square rods, grind ladder grooves, drill raindrops, split for a feather, stand slices on end) is written as an exact map from the finished blade back to where that steel came from, and every pixel of the blade face is pulled back through the whole history in reverse. The face is a plane through the billet that dives toward the middle along the edge bevel, so grinding deeper changes the pattern just as it would on a real knife. The etch is antialiased with the screen-space gradient of the layer coordinate, and the shading treats the etched nickel as slightly proud and brushed along the blade, reflecting a softbox that drifts across the steel.

Try it. Click the anvil buttons to fold, twist, ladder, raindrop, feather, turn or wave the billet and watch the pattern re-form; Undo pops the last step. Drag across the blade to twist it live, drag up or down to grind deeper, and click the blade to punch a dimple. The inset shows the billet's end grain under the pointer with the ground face drawn across it. Keys: F, T, L, R, E, U, W for the operations, Z to undo, N for a new billet, arrows to grind.

  • Inverse coordinate maps
  • Function composition
  • Antialiased parity etch
  • Normal mapping
  • Anisotropic brushed shading

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 Damascus steel pattern 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.

The idea: a forged billet is just layers of light and dark steel that have been moved around. Instead of simulating the forging, write each step as a function that takes a point on the finished blade and returns where that bit of steel was before the step. Run every pixel backwards through all the steps, and color it by which layer it lands in.

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens, and has a dark background.
- Draw a long rectangle for the blade. For each pixel in it, compute x (along the blade, 0 to 5), y (across, 0 to 1) and w = 0.8 (the height of the ground face inside the billet).
- Keep a list of steps. Pull the point back through them in reverse order, then color it light if floor(13 * w) is even and dark if it is odd. Render into an ImageData at half resolution and scale it up.
- Implement three steps: fold (w = 2w if w < 0.5, else 2 - 2w), twist (rotate y and w about the bar's centre by an angle proportional to x), and raindrop (push w down near points on a hex grid with a Gaussian bump).
- Add buttons that append each step and redraw.

Once that works, make it beautiful:
- Animate a new step by scaling its strength from 0 to 1 over a second, so the pattern morphs.
- Antialias the layer edges using how fast floor(13 * w) changes between neighbouring pixels.
- Shade the steel: bright layers silver and glossy, dark layers nearly black, with a soft highlight band that drifts along the blade.

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 splitting the billet into several twisted bars, a knife-shaped outline with a bevel that dives deeper into the billet, or a cross-section view of the billet's end grain.
PreviousFourier EpicyclesA chain of spinning circles traces any drawing you give it. NextRotating DrumGrains in a turning drum avalanche and sort themselves: big outside, small in the core.

Related visualizations

  • Blacksmith's ForgePhysics Heat, hammer and quench a steel bar whose glow and temper colors come from physics.
  • Paper MarblingGenerative art Ink drops, combs and styluses on a size bath, then a print pulled onto paper.
  • Rose EngineGenerative art A simulated rose engine lathe cuts banknote-fine guilloche, one pass at a time.
  • Millefiori CaneGenerative art Build glass canes by casing, moulding and bundling, then slice them into a paperweight.
  • Engraving Renderer3D A moving 3D still life printed as a copperplate engraving, line by swelling line.
  • KintsugiGenerative art A glazed tea bowl shatters along branching cracks, then is mended with flowing gold.
  • Girih Star PatternsGenerative art Interlaced Islamic star patterns built live from one angle over a hidden tiling.
  • Topographic SurveyGenerative art Eroded terrain printed as a survey sheet with labeled contours, streams and hillshade.
  • Chrome Blob3D A wobbling liquid metal droplet with real reflections, rasterized by hand.

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

← More from Emergent Mind Labs