Mandelbrot set visualisation written in Python and accelerated with PyCUDA
- Python 2.7+ or Python 3+
- Pillow
- PyCUDA (optional, for CUDA compatible devices)
- PyQt 4 or 5 (optional, for GUI)
python mandelbrot.py [-h] [--size SIZE] [--plane PLANE] [--tasks TASKS] [--output OUTPUT] [--quiet QUIET] [--mode MODE]
--size SIZE, -s SIZE
Description: The output image size, example format: 500x500
Default: 500x500
--plane PLANE, -p PLANE
Description: The real and imaginary axis range, example format: -2.0:1.0:-1.5:1.5, where [-2.0, 1.0] is the real axis range and [-1.5, 1.5] is the imaginary axis range.
Default: -2.0:1.0:-1.5:1.5
--tasks TASKS, -t TASKS
Description: The number of concurrent CPU tasks to generate the visualisation.
Default: 1
--output OUTPUT, -o OUTPUT
Description: The output filename.
Default: mandelbrot.png
--quiet QUIET, -q QUIET
Description: Quiet mode (no verbose logs)
Default: 0 (verbose)
--mode MODE, -m MODE
Description: 0 for GUI, 1 for console mode
Default: 0 (GUI)
--gpu GPU, -g GPU
Description: GPU acceleration mode if set to 1 (true). Only available when there is a CUDA-capable device and PyCUDA is installed. If set to 0 (default), the script runs in CPU acceleration.
Default: 0 (CPU)
You can also create a custom color scheme that will be used in the visualisation.
Simply change the COLOR_PALETTE list in the other/generate_color_scheme.py
script with five or more main colors you would like to use and run:
python other/generate_color_scheme.py [COLORS]
where [COLORS]
is the number of colors you want to generate (default: 512). Typically it should be equal to the MAX_ITERATIONS
constant in mandelbrot/constants.py
.
Other sample images can be found in screens
directory.
Command used: python mandelbrot.py -m 1 -g 1 -s 4096x4096 -p="-0.78:-0.76:-0.12:-0.10" -o seahorse_valley.png
Command used: python mandelbrot.py -m 1 -g 1 -s 4096x4096 -p="0.27:0.28:0:0.01" -o elephant_valley.png
Command used: python mandelbrot.py -m 1 -g 1 -s 4096x4096 -p="-1.79:-1.71:-0.04:0.04" -o mini_mandelbrot_2.png
Any contributions are welcomed! Feel free to contribute by opening a pull request.