This repository contains the code for the Fract-ol project, including both mandatory and bonus parts.
The fract-ol
project from the 42 School is one of the three "beginner" graphical projects of the cursus. It teaches you about manipulating a low-level graphic library, advanced math, and more.
The program is written in C language and thus needs the gcc compiler and some standard C libraries to run. In addition to that, you will need the MinilibX library, of course.
-
Clone the repository
git clone https://github.com/AnaVolkmann/42_FRACTOL.g
-
To compile the program, run the following command
make
-
To execute the program, use the following command
./fractol <fractal>
Available commands:
mandelbrot
,julia
.
The program supports the following controls:
Mouse Scroll | Zoom |
⬆️ ⬇️ ⬅️ ➡️ | Move the view |
SHIFT | Shift the color range |
- and + | Decrease or increase the max iterations |
SPACE | Generate new constants for the Julia fractal |
ESC | Close the program window |
🚀 The lower the iterations, the faster the program will run. 🐢 The deeper the zoom, the more iterations are needed to render the fractal, the slower the program.
Fractals are formed by mathematical suites.
For example, the Julia and Mandelbrot sets are defined by the following suite:
Fractals are based on complex numbers (i.e. numbers with a real and imaginary part, like
-
The
$a$ (real) part of the complex number is represented on a x-axis. -
The
$b$ (imaginary) part of the complex number is represented on a y-axis. -
This means that the coordinates
$(3, 7)$ represent number$z = 3 + 7i$ , and that every pixel of a window can be used to represent a complex number. -
Every complex number put into the suite will either:
- converge to a finite number
- diverge to infinity.
-
The pixels of the window can be colored depending on whether the complex number they represent converges or diverges.