$ OCaml Mandelbrot Set

View on GitHub →

An interactive Mandelbrot set explorer written in OCaml using the Graphics library. The Mandelbrot set is the set of complex numbers c for which the iteration z = z² + c (starting from z = 0) remains bounded.

Points inside the set are colored black; points outside are colored based on how many iterations it takes to escape, producing the characteristic fractal boundary with infinite complexity at every scale.

### features

  • - Interactive Zoom — Click to zoom in 2x centered on cursor, or use +/- keys
  • - Pan Navigation — Use arrow keys or vim-style (h/j/k/l) to pan around
  • - Smooth Rendering — Real-time rendering with escape-time algorithm
  • - Color Gradients — Points outside the set colored by iteration count
  • - Reset View — Return to the original coordinates with 'r' key

### controls

Click — Zoom in 2x at cursor position
+ / = — Zoom in 2x at cursor position
- — Zoom out 2x at cursor position
h / a / ← — Pan left
l / d / → — Pan right
j / s / ↓ — Pan down
k / w / ↑ — Pan up
r — Reset to original view
q / Esc — Quit

### build & run

prerequisites

opam install . --deps-only

build

dune build

run

dune exec mandelbrot

### learn more

Explore the mathematics behind the Mandelbrot set and browse the source code.