Skip to content

JMADIL/FRACT-OL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌀 Fract-ol

Explore the beauty of fractals — 42 Network project

42 School Language License


📖 About

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.

✨ Features

  • 🎨 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

🚀 Getting Started

Prerequisites

  • GCC compiler
  • Make
  • miniLibX (included or install via package manager)
  • X11 libraries (sudo apt install libx11-dev libxext-dev on Ubuntu)
  • A UNIX-based OS (Linux / macOS)

Build

git clone https://github.com/JMADIL/FRACT-OL.git
cd FRACT-OL
make

Usage

# 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

Controls

Input Action
Scroll Up Zoom in (follows cursor)
Scroll Down Zoom out (follows cursor)
Arrow Keys Pan the view
ESC Exit

📂 Project Structure

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

🏗️ How It Works

The Mandelbrot Set

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)

The Julia Set

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)

Color Mapping

Iteration count ──► Color value
     0          ──► Dark (deep inside the set)
     1-10       ──► Blues & purples
     10-50      ──► Greens & yellows
     50+        ──► Reds & whites (near the boundary)

🔑 Key Concepts Learned

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

👤 Author

Adil Jamoun@JMADIL

🏫 1337 Coding School (42 Network) — Morocco

About

A graphical engine designed to render and explore infinite mathematical fractals, specifically the Mandelbrot and Julia sets. It maps complex numbers to screen coordinates, calculating pixel behavior to allow smooth zooming and panning in real time.

Topics

Resources

Stars

Watchers

Forks

Contributors