Fractol is a graphic project of 42 school curiculum realised in C. The aim of this project is to program a Fractals explorer (see project subject here or in ressource_and_assets repository).
The main objectives of the project is to:
- use the minilibX graphic library,
- tackle complex number in a programming project,
- address the problem of optimization in graphic project.
git clone https://github.com/madvid/fractol
cd fractol && ./fractol <available fractal>
The program expects a parameter being the name of one of the available fractals. Without parameter the usage will be displayed:
usage:
./fractol [fractal name]
[fractal name] has to be one of the following:
Julia
Mandelbrot
BurningShip
Newton
Open the Mandelbrot fractal ⇣
./fractol Mandelbrot
Default colorscale is viridis, this can be changed in the source code in the file mlx.c
line 39. To see the available colorscale, refers colorscale functions to the files colorscale1.c
and colorscale2.c
.
When fractol program is running, you can interact with the fractal representation via a collection of actions;
- translations,
- zoom,
- colorscale change.
- reset render parameters to the initial values,
- modify the degree of the complex polynom in fractal formula (Mandelbrot and Julia only)
Translations can be performed via the following keyboard buttons:
Description | Key(s) |
Tiny translation to the up | ▲ |
Tiny translation to the down | ▼ |
Tiny translation to the left | ◄ |
Tiny translation to the right | ► |
Translation to the up | z |
Translation to the down | s |
Translation to the left | q |
Move the fractal to the right | d |
Zoom/Unzoom operations can be performed via the following keyboard buttons:
Description | Key(s) |
Increase the global size of the fractal / zoom | + |
Decrease the global size of the fractal / unzoom | - |
You can change the colorscale used in the rendering by using the keyboard button of the pad:
Description | Key(s) |
viridis | 1 |
magma | 2 |
YlOrBr | 3 |
mako | 4 |
Coolwarm | 5 |
Blue shades | 6 |
Red shade | 7 |
Green shade | 8 |
You can also performed zoom and unzoom operations via the mouse:
Description | Control(s) |
Increase the global size of the fractal / zoom | scroll up |
Decrease the global size of the fractal / unzoom | scroll down |
All the render related parameters (ratio, translation, degree and colorscale) can be reset to their initial values by pressing sapce .
Mandelbrot and Julia fractal have a complex number elevated to power 2 by default (and it is the formula one can find easily on internet). You have the possibility to modify the degree by pressing keyboard button between 1 and 6 except for Julia fractal where the degree is limited to 3 (but it can be modified in the header file).
Fractol can be existed normally in 2 ways:
- clicking the cross of the window,
- pressing the button esc
- (and by doing ctrl + c but it is not specifically handled by the program :) )
Based on your system and keyboard configuration, the interactions may not work. This is due to key value corresponding to the button pressed. You need to refer to the key values mapping of your system/keyboard and modify the macros in the right part (apple / linux or add an extra part).
This Jupyter notebook contain the python code developped to adjust several polynomial models on the different coloscale in the Seaborn python library. The coefficients of the polynomial models are printed at the end of the notebook according to a preformated C format code adapted for my code (compare this output in jupyter notebook and the expression in the colorscale C files), we just need to copy/paste the output directly.