Visualizations
008 / 500

008 · Generative art

Procedural City

An isometric city that builds itself and runs through day and night.

The city grows from a seed: a coastline and harbor, a river with bridges, a road grid, and lots zoned into towers, midrises, houses and parks with noise. Every building is extruded in isometric projection and sorted by depth. Cars follow the roads, windows light up at dusk, and a full day and night cycle shifts the light, shadows and sky.

Try it. Click to build a new city. Drag to pan.

  • Isometric projection
  • Procedural generation
  • Depth sorting

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 an isometric procedural city 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 resizes with the window.
- Use a 20 by 20 tile grid and an isometric projection: a world point (x, y, z) lands on screen at ((x - y) * tileWidth / 2, (x + y) * tileWidth / 4 - z * heightScale), shifted to the middle of the canvas.
- Generate the city from a seeded random number generator: lay roads along every fifth row and column, and treat every other tile as a lot.
- Put a building on most lots: a box with a random height, taller toward the center of the map. Draw only the three faces you can see (the top and the two front walls), each a slightly different shade of the same color so the boxes read as solid.
- Draw the ground first, then the buildings sorted back to front by x + y (the painter's algorithm) so nearer buildings cover farther ones.
- Click to generate a new city from a new seed.

Once that works, make it beautiful:
- Light every face from a sun direction with a simple dot product, plus an ambient sky color, and animate the sun through a day so colors shift from noon blue to golden hour to night.
- Add shadows by projecting each building's top along the sun direction onto the ground and filling the outline.
- Add rows of windows that light up warm yellow at dusk, a few parks with round trees, and a soft sky gradient behind it all.

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 cars driving along the roads, a river with bridges, or pitched roofs on the smaller houses.
PreviousNeon SignType a word and watch it get bent into glowing glass tubes on a brick wall. NextHyperbolic TilingAn endless koi garden of {p,q} ponds tiling the Poincare disk, with fish circling.

Related visualizations

  • Interior Mapping3D A night skyline of thousands of furnished, lit rooms, and not one of them has geometry.
  • Impossible ArchitectureIllusions Walkers climb Penrose stairs forever on a pastel tower whose paths only meet on screen.
  • Invented AtlasGenerative art A parchment map of a world that never was, with rivers, realms and its own language.
  • Basalt ColumnsNature Cooling lava cracks into columns that drift toward hexagons, on an isometric causeway.
  • Painterly RenderingGenerative art A harbor at dusk repainted coarse to fine in thousands of curved, bristly strokes.
  • Near Light SpeedPhysics Drive a city street near light speed and see what relativity really does to the view.
  • PlanetAstronomy A procedurally generated world with oceans, clouds and a glowing atmosphere.
  • Evolved TrianglesGenerative art Two hundred translucent triangles evolve from chaos into a painted landscape.
  • Pseudo 3D RoadRetro A sunset coastal highway faked the 80s arcade way, from flat segments and sprites.

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

← More from Emergent Mind Labs