A fractal is a fragmented geometrical figure that infinitely repeats at smaller scales.
So this project generates beautiful fractals from the complex numbers of an iterative mathematical construct.
For graphics, I used SFML library and NVIDIA CUDA Toolkit for parallel computing.
Project builds by CMake build system, so if you do not have CUDA Toolkit or your platform doesn't have
CUDA support, CMake will build this project without CUDA support and computing will be done through CPU threads.
By default, there will be 40 parallel threads, the color is rgb(21, 0, 0) and the window size is 800px.
Note
If you want to change color, threads count, window size, or other defaults, change them in helpers.hpp file.
The program supports these fractal sets:
Name | Formula |
---|---|
Mandelbrot | |
Julia | |
Burning Ship | |
Tricorn | |
Mandelbox | It's more complex, see this article |
Multibrot | |
Mandelbar | Take a look at Mandelbar 5th (horizontal) in this image |
Per. Burning Ship | Take a look at Perpendicular Burning Ship in this image |
Celtic Mandelbrot | Take a look at Celtic Mandelbrot in this image |
https://www.deviantart.com/kosmic-stardust/art/Mandelbrot-ABS-Variations-Complete-Set-of-Formulas-487039852 https://www.deviantart.com/kosmic-stardust/art/4th-Order-ABS-Mandelbrot-Variations-Complete-Set-601300868 https://www.deviantart.com/kosmic-stardust/art/5th-Order-ABS-Mandelbrot-Variations-601484985
The program supports the following controls:
Key | Description |
---|---|
ESC | Close the program window |
Keys [1-9] | Move to another fractal |
Key R | Change the red component of fractal |
Key G | Change the green component of fractal |
Key B | Change the blue component of fractal |
Mouse Scroll | Zoom in and out of the fractal |
โฌ๏ธ โฌ๏ธ โฌ ๏ธ โก๏ธ | Change the viewpoint |
Key L | Lock Julia's fractal |
Zero | Reset the fractal to its initial state |
The program is written in C++ and thus needs the g++ compiler and some standard C++ libraries to run.
Also needs to install SFML library and CMake. If you want to use your NVIDIA GPU power, you need to install NVIDIA CUDA Toolkit.
1. Compiling the program
To build the release version, run these commands:
$ cd path/to/fractal
$ mkdir Release
$ cd Release
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make
To build the debug version, run these commands:
$ cd path/to/fractal
$ mkdir Debug
$ cd Debug
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
$ make
2. How to run the program
Run the executable too see the help message:
./fractal
Or run with some supported fractal:
./fractal mandelbrot
Note
For CUDA support, you need to install CMake version >= 3.24
If you want to disable CUDA support, just uncommnet line 19 in CMakeLists.txt file.