Hi,
I have been working on a small python program (rather, a long script) to generate images for different Mandelbrot sets - for the moment:
- the classical z → z² + c
- Mandelbrot sets for rational functions with a higher monome degree ≥ 2 – ie with a super-attractive fixed point at infinity
I know that there are a lot of more user-friendly / optimized / deep-zooming programs out there. It suffers from some obvious flaws (speed, ...) but I am pleased with some image it produces.
Following a discussion on this site it seems some people could be interested by the program / source code, so here we go.
This program itself is written in python (python 2.7, I should have switched to python3 some time ago…) and uses the following dependencies: numpy, matplotlib, Pillow.
Here I share the part for the classical Mandelbrot (I need some more time to tidy the code for rational maps, which I will do later on if some manage to run this code and are interested for more)
It is composed of 3 files:
fractal.py Main low-level part, defining 4 classes
- Color_tools for color operation in CIE color space (shading, color gradient, …)
- Fractal_colormap maps floats to colors
- Fractal_plotter plots a fractal object
- Fractal abstract base class encapsulating a fractal object, to be subclassed
classical_mandelbrot.py defines the class Classical_mandelbrot (z → z² + c) – subclass of Fractal
run_mandelbrot.py runs calculations to produce 4 plots (intended as working example). The first one is only ‘draft mode’ I use it for exploring, for the 3 other I will put below the output of the program.
To run the program you need to have installed python 2.7, numpy, Pillow and matplotlib. If you do not have I personally use the Anaconda distribution which ships all these (and a lot more...), opensource and available for windows, mac, linux.
https://www.anaconda.com/products/individualThen simply put the 3 files in the same directory and launch run_mandelbrot.py from your preferred development environment – I use Spyder) -
"""=====================================================================
Run the script to generate 1 of 4 fractal images
User-input needed : *choice* and the target *directory*
===================================================================="""
License:
Feel free to ignore, use or include in your own source code. However if you enjoy or include it I would be happy to know!
Linkback: https://fractalforums.org/programming/11/a-mandelbrot-script/3546/