Explore the beauty of fractals — 42 Network project
Fract-ol is a 42 school project that renders beautiful mathematical fractals in real-time using the miniLibX graphics library. By implementing the Mandelbrot and Julia sets, you can zoom infinitely into stunning, self-similar patterns — all generated from simple mathematical formulas.
This project is an exploration of complex numbers, iterative algorithms, and computer graphics.
- 🎨 Mandelbrot Set — The iconic fractal with infinite zoom
- 🌈 Julia Set — Parametric fractal with customizable constants
- 🔍 Infinite Zoom — Scroll to zoom in/out with mouse cursor tracking
- 🖱️ Mouse Navigation — Zoom follows the cursor position
- ⌨️ Keyboard Controls — Arrow keys to pan the view
- 🎭 Color Palettes — Psychedelic color mapping based on iteration count
- GCC compiler
- Make
- miniLibX (included or install via package manager)
- X11 libraries (
sudo apt install libx11-dev libxext-devon Ubuntu) - A UNIX-based OS (Linux / macOS)
git clone https://github.com/JMADIL/FRACT-OL.git
cd FRACT-OL
make# Render the Mandelbrot set
./fractol mandelbrot
# Render a Julia set with custom parameters
./fractol julia <real> <imaginary>Examples:
./fractol julia -0.766667 -0.090000 # Classic Julia spiral
./fractol julia 0.285 0.01 # Dendrite pattern
./fractol julia -0.4 0.6 # Lightning bolts| Input | Action |
|---|---|
Scroll Up |
Zoom in (follows cursor) |
Scroll Down |
Zoom out (follows cursor) |
Arrow Keys |
Pan the view |
ESC |
Exit |
FRACT-OL/
├── Makefile # Build system
├── fractol.h # Header with structs & prototypes
├── main.c # Entry point & argument parsing
├── init_fract.c # Fractal initialization & window setup
├── fractal_render.c # Mandelbrot & Julia rendering algorithms
├── events.c # Mouse & keyboard event handlers
└── utils/ # Utility functions
For each pixel (x, y) on screen, map it to a complex number c = a + bi, then iterate:
z₀ = 0
zₙ₊₁ = zₙ² + c
If |zₙ| > 2 → pixel is OUTSIDE (color based on iteration count)
If iterations reach max → pixel is INSIDE (typically black)
Similar to Mandelbrot, but c is a fixed constant and z₀ varies per pixel:
z₀ = pixel position
zₙ₊₁ = zₙ² + c (c is constant, e.g., -0.766667 - 0.09i)
Iteration count ──► Color value
0 ──► Dark (deep inside the set)
1-10 ──► Blues & purples
10-50 ──► Greens & yellows
50+ ──► Reds & whites (near the boundary)
| Concept | Description |
|---|---|
| Complex Numbers | Working with real + imaginary components |
| Iterative Algorithms | Convergence/divergence testing per pixel |
| miniLibX | Pixel-level rendering and event handling |
| Color Theory | Mapping iteration depth to RGB color values |
| Coordinate Mapping | Screen pixels ↔ complex plane coordinates |
| Optimization | Efficient rendering for real-time interaction |
Adil Jamoun — @JMADIL
🏫 1337 Coding School (42 Network) — Morocco