A fractal visualization program that renders beautiful mathematical fractals using the MiniLibX graphics library.
Fract-ol is a project that explores the fascinating world of fractals. It renders complex mathematical sets like the Mandelbrot and Julia sets in real-time, with interactive zoom, color manipulation, and parameter changes. This project teaches computer graphics, mathematical algorithms, and optimization techniques.
- Multiple Fractal Types: Mandelbrot set, Julia set, and custom fractals
- Real-time Rendering: Smooth zooming and panning
- Interactive Controls: Mouse and keyboard navigation
- Color Schemes: Multiple color palettes and gradients
- High Performance: Optimized rendering algorithms
- Parameter Adjustment: Real-time Julia set parameter changes
The famous fractal defined by the iteration: z = z² + c
Similar to Mandelbrot but with fixed complex parameter: z = z² + c
Additional mathematical sets and variations
make- Clone the repository:
git clone https://github.com/bratzwitch/fractol.git
cd fractol- Compile the program:
make- Run with fractal type:
./fractol mandelbrot
./fractol julia
./fractol [custom_fractal_name]- Scroll Up/Down: Zoom in/out
- Left Click: Center view on clicked point
- Mouse Movement: Real-time Julia set parameter change (Julia fractal)
- Arrow Keys: Pan view (up, down, left, right)
- +/-: Zoom in/out
- Space: Reset view to default
- C: Change color scheme
- I: Increase iterations (better quality, slower)
- D: Decrease iterations (lower quality, faster)
- ESC: Exit program
Basic usage:
# Render Mandelbrot set
./fractol mandelbrot
# Render Julia set
./fractol julia
# Custom parameters (if supported)
./fractol julia -0.7 0.27015For each point c in the complex plane:
- Start with z₀ = 0
- Iterate: zₙ₊₁ = zₙ² + c
- If |z| remains bounded after many iterations, c is in the set
For a fixed complex parameter c:
- For each point z₀ in the complex plane
- Iterate: zₙ₊₁ = zₙ² + c
- If |z| remains bounded, z₀ is in the set
int mandelbrot(double real, double imag, int max_iter)
{
double z_real = 0;
double z_imag = 0;
double temp;
int iter = 0;
while (z_real * z_real + z_imag * z_imag <= 4 && iter < max_iter)
{
temp = z_real * z_real - z_imag * z_imag + real;
z_imag = 2 * z_real * z_imag + imag;
z_real = temp;
iter++;
}
return (iter);
}- Escape Radius: Early termination when |z| > 2
- Iteration Limits: Configurable maximum iterations
- Pixel-level Calculations: Direct coordinate mapping
- Color Interpolation: Smooth color transitions
fractol.c: Main program and initializationmandelbrot.c: Mandelbrot set implementationjulia.c: Julia set implementationcontrols.c: Mouse and keyboard event handlingutils.c: Helper functionscolors.c: Color scheme managementfractol.h: Header file with prototypesMakefile: Compilation rules
The program supports multiple color palettes:
- Classic: Traditional blue-white gradient
- Fire: Red-orange-yellow gradient
- Rainbow: Full spectrum colors
- Psychedelic: Vibrant, contrasting colors
- Monochrome: Grayscale variations
- Lower iteration counts for real-time interaction
- Higher iteration counts for detailed final renders
- Zoom gradually for smooth experience
- Use appropriate window size for your system
- MiniLibX: Graphics library (provided by 42)
- GCC: Compiler
- Make: Build system
- X11: For Linux systems
- Math Library: Link with
-lm
MacOS:
# MiniLibX is usually provided by 42Linux:
sudo apt-get install xorg libxext-dev zlib1g-dev- Invalid arguments validation
- Memory allocation checking
- Window creation verification
- Mathematical overflow protection
# Test different fractals
./fractol mandelbrot
./fractol julia
# Test zoom and navigation
# Use mouse wheel and arrow keys
# Test color changes
# Press 'C' while program is runningPossible enhancements:
- Burning Ship: Alternative fractal formula
- Newton's Method: Root-finding fractals
- Phoenix: Additional Julia-type fractal
- 3D Fractals: Mandelbulb visualization
Viacheslav Moroz - 42 Student