Computer Science Framogen

Framogen

Fractal Mountain Generator using Diamond-Square algorithm

Controls
Generation
Terrain
Display

Space/R: regenerate | A: animate
V: toggle 3D | +/-: zoom | 0: reset
Mouse wheel: zoom | Drag: pan

Diamond-Square Algorithm

The Diamond-Square algorithm is a fractal terrain generation method that creates realistic heightmaps through recursive subdivision.

Steps:

  1. Initialize corners of a square grid with random values
  2. Diamond step: For each square, set its center to the average of its 4 corners + random offset
  3. Square step: For each diamond, set its center to the average of its 4 points + random offset
  4. Reduce the random offset (roughness decay)
  5. Repeat until all grid points are filled

Complexity: O(n²) where n = grid size

Color mapping: Heights are normalized to [0,1] and mapped to terrain colors (ocean → sea → beach → grass → forest → rocks → snow).

© 2013 - 2026 Cylian