Skip to content

A small script written in Python3 that generates a visual representation of the Mandelbrot set.

License

Notifications You must be signed in to change notification settings

BillyDoesDev/mandelbrot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mandelbrot Set Generator

A small script written in Python3 that generates a visual representation of the Mandelbrot set.

Mandlebrot set

Abstract

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: $$z_{n+1} = (z_n)^2 + c, z_0 = 0$$ ...where $c$ is a constant complex number.

Dependencies

  • Pillow
    To get it installed, simply do:
pip install Pillow

Installation

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

Customizing output

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)
    ),
)

About

A small script written in Python3 that generates a visual representation of the Mandelbrot set.

Topics

Resources

License

Stars

Watchers

Forks

Languages