A real-time interactive fractal explorer written in C using the MiniLibX graphics library. Built as a project at 42/1337 school.
- About
- Supported Fractals
- Screenshots
- Requirements
- Installation
- Usage
- Controls
- Features
- Project Structure
- How It Works
- Author
fract-ol is a graphical exploration tool for mathematical fractals. It renders the Mandelbrot set, Julia sets, and the Burning Ship fractal in real time, with smooth coloring, infinite zoom, panning, and interactive parameter manipulation. The project demonstrates low-level graphics programming, complex number mathematics, and event-driven design in C.
| Fractal | Description |
|---|---|
| Mandelbrot | The classic Mandelbrot set, defined by iterating |
| Julia | A family of fractals using |
| Burning Ship | A variation of the Mandelbrot set that takes the absolute values of the real and imaginary parts before squaring, producing a ship-like shape. |
| Mandelbrot | Julia | Burning Ship |
|---|---|---|
![]() |
![]() |
![]() |
| Zoom Demo | Julia Map | Disco Mode |
|---|---|---|
![]() |
![]() |
![]() |
- Linux (X11 window system)
- GCC or compatible C compiler
- X11 development libraries (
libXext,libX11) make,git
- Install dependencies:
sudo apt update && apt install -y git make gcc libx11-dev libxext-dev libbsd-dev libzip-dev- Clone the repository:
git clone https://github.com/saidmakkass/fractol.git fractol
cd fractol- Build the project:
makeOn the first build, the Makefile automatically clones and compiles the MiniLibX library from source. It then compiles the custom libft library and all source files, and links everything together.
./fractol <fractal> [options]
| Argument | Fractal |
|---|---|
M or Mandelbrot |
Mandelbrot set |
J or Julia |
Julia set |
B or Burning_ship |
Burning Ship fractal |
Arguments are case-insensitive.
| Option | Description | Default |
|---|---|---|
-s <WxH> |
Set the window size in pixels | 600x600 |
-j <c> |
Set the Julia constant as a complex number | 0.285 + 0.01i |
./fractol Mandelbrot
./fractol Julia -j "-0.8 + 0.156i"
./fractol Burning_ship -s 800x800
./fractol J -j "0.355 + 0.355i" -s 900x900Press P while running to display an on-screen overlay of all controls.
| Key / Input | Action |
|---|---|
| Arrow keys | Pan the view |
| Mouse scroll up | Zoom in (centered on cursor) |
| Mouse scroll down | Zoom out (centered on cursor) |
+ |
Zoom in |
- |
Zoom out |
| Key | Action |
|---|---|
] |
Increase max iterations (+10) |
[ |
Decrease max iterations (-10, minimum 10) |
' |
Next color scheme |
; |
Previous color scheme |
O |
Toggle disco mode (animated color cycling) |
| Key | Action |
|---|---|
F |
Cycle to the next fractal type |
M |
Toggle the Julia map window (Julia set only) |
The Julia map opens a secondary 300x300 window showing the Mandelbrot set. Click and drag on the map to interactively change the Julia constant c in real time.
| Key | Action |
|---|---|
R |
Reset view to defaults |
P |
Toggle info overlay |
Escape |
Quit |
- Real-time rendering -- Fractals are computed and displayed pixel by pixel with immediate visual feedback on every interaction.
- Smooth sinusoidal coloring -- Colors are generated using offset sine waves across RGB channels, producing smooth gradients that highlight fractal detail.
- Cursor-centered zoom -- Mouse wheel zoom tracks the cursor position, allowing precise exploration of specific regions.
- Dynamic iteration control -- Increase or decrease the iteration depth on the fly to balance detail and performance.
- Interactive Julia map -- A secondary window renders the Mandelbrot set and lets you click and drag to pick Julia constants in real time, immediately updating the main fractal view.
- Disco mode -- Continuously cycles through color schemes for an animated visual effect.
- Fractal cycling -- Switch between all three fractal types without restarting the program.
- On-screen info overlay -- Displays the current fractal type, iteration count, and a full list of controls directly on the window.
- Custom window size -- Configure the rendering resolution from the command line.
- Proper resource cleanup -- All MiniLibX resources, images, and windows are properly freed on exit.
fractol/
├── Makefile Build system
├── include/
│ └── fractol.h Header with structs, prototypes, and constants
├── minilibx-linux/ MiniLibX (cloned automatically on first build)
├── libft/ Custom C standard library
│ ├── Makefile
│ ├── libft.h
│ └── *.c String, memory, list, and I/O utilities
└── src/
├── main.c Entry point, MLX initialization, event loop
├── parsing.c Command-line argument parsing
├── error.c Cleanup, usage message, and error handling
├── plot.c Pixel plotting and fractal rendering loop
├── mandelbrot.c Mandelbrot set computation
├── julia.c Julia set computation
├── burning_ship.c Burning Ship fractal computation
├── color.c Sinusoidal RGB color mapping
├── info.c On-screen info and controls overlay
├── key_hook.c Keyboard event handlers
├── mouse_hook.c Mouse event handlers (zoom)
├── loop_hook.c Main loop hook (disco mode, Julia map drag)
├── map.c Julia map window creation and rendering
├── map_hooks.c Julia map window event handlers
└── ft_atof.c String-to-double conversion utility
Each pixel on screen is mapped to a point on the complex plane. The program applies the corresponding fractal iteration formula to that point and counts how many iterations it takes to escape a radius of 2 (escape threshold
Points that never escape within the maximum iteration limit are colored black, representing the interior of the fractal set.
Zooming works by adjusting a scale factor that controls how much of the complex plane is visible per pixel. Panning shifts the origin offset. All transformations are applied each frame, so the fractal is re-rendered on every interaction.
smakkass -- 42/1337 School
- Intra: smakkass






