Skip to content

This library draws the Mandelbrot set and writes it out as a bitmap file

License

Notifications You must be signed in to change notification settings

lobophf/mandelbrot-set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mandelbrot set

screenshot screenshot
GitHub language count GitHub last commit License
About   |   Installation   |   Using   |   License

❓ About:

This library draws the Mandelbrot set and writes it out as a bitmap (BMP) file. To know more about this subject, please see this page. You can do as I did and get additional information by checking John's course on Udemy.

🛠️ Installation:

First, clone this repository and jump into the mandelbrot-set folder.

$ git clone git@github.com:lobophf/mandelbrot-set.git 
$ cd mandelbrot-set

You can easily modify the Makefile available in this repository, to include this library in your project. Once you've done it, just type:

$ make

If you run the program, the bitmap file will be placed wherever you have set it. See the main.cpp file for reference.

⚙️ Using:

I'm still improving this library in order to make it easier to use. For now, to create the images by yourself, you need to know some stuff shown below.

First off, add the FractalCreator.h header into your code, and put the FractalCreator object, passing the width and height as arguments.

#include "includes/fractalCreator.h"

int const WIDTH = 1600;
int const HEIGHT = 800;
FractalCreator frac(WIDTH, HEIGHT); 

Now, you must use the addRange method to define the histogram colors. The first argument is a position in the scale, between 0 and 1 to be marked by some color. The RGB struct, as the name suggests, is the color itself in RGB format. It is necessary to provide at least the values at these two bounds.

frac.addRange(0.0, RGB(  0,   0,   0));
/* Set some additional colors in the middle 
   of the scale range. */
/* 
frac.addRange(0.4, RGB(  0, 230, 255));
frac.addRange(0.8, RGB( 72,   0, 255));
*/
frac.addRange(1.0, RGB(  0,   0, 255));

Then, you must use the Zoom structure combined with the addZoom method to navigate over the bitmap image. The first two arguments of the Zoom struct are the pixel coordinates. By default, the start position is centered at the origin of the complex plane. The third argument is a number that represents the zoom. The lower its value, the deeper we go into fractals.

You can "add zooms" many times you want to plan your trip. However, keep in mind that at each step, you must choose a new pixel as the zoom focus, based on the image dimensions.

frac.addZoom(Zoom( 500, 366, 0.10));
frac.addZoom(Zoom( 522,  20, 0.05));
frac.addZoom(Zoom(1268, 106, 0.30));

Finally, the run method creates the bitmap file, whose address is passed as an argument.

frac.run("outputs/test.bmp");

⚖️ License

This application is a MIT licensed, as found in the LICENSE file.

About

This library draws the Mandelbrot set and writes it out as a bitmap file

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published