A small script written in Python3 that generates a visual representation of the Mandelbrot set.
The colors in the output image are in HSV format. The darker pixels represent those areas where the least recursion was made (basically those parts which do not belong in the set), and vice-versa. The algorithm used is, of course:
- Pillow
To get it installed, simply do:
pip install Pillow
To get started, simply clone the repo, cd into it and run it.. it's as easy as it gets...
git clone https://github.com/BillyDoesDev/mandelbrot.git
cd mandelbrot
python main.py
The image will be saved in the current working directory as output.png
You may change the resolution of the output image by changing its height and width in main.py
# Image size (pixels)
WIDTH = 3840
HEIGHT = 2160
Further, you may change the recursion depth in mandlebrot.py
MAX_ITER = 1e2
The darker pixels represent those areas where the least recursion was made.
In the code snipplet below, color
represents the brightness. You may obviously change the HSV values as you want in main.py
draw.point(
[x, y],
tuple(
round(i * 255)
for i in colorsys.hsv_to_rgb(<hue> / 360, <saturation> / 100, color / 100)
),
)