Image generation of various fractals in the complex plane.
Built with Python 3.7.8, Numpy, and Numba.
- Add additional fractals (3rd and 4th powers)?
- Have .animate() create an .mp4 or .gif rather than a series of images.
- Real time color map previews with adjustable phase inputs.
- Real time viewer of fractals to explore and find inputs to use for final renders.
- todo - generic about segment
Each fractal is generated using an iterative function. The mandelbrot, for example, uses the function   where   and   are both complex numbers in the form   with   . Here   is a constant representing the coordinate of a pixel and   is the point   in the complex plane. The point is iterated until it either escapes a given radius from the origin or the iteraiton count limit is hit. Points which do not escape are said to be part of the set (typically colored black), and points that do diverge are colored based on their highest iteration count before they escaped. The coloring is smoothed to give a nicer looking output.
# After cloning the repository and navigating to the directory
$ python -m venv venv
$ .\venv\scripts\activate
$ pip install -r requirements.txt
from complex_fractals import * # import all classes and functions
ComplexFractal("list") # list all identifiers to console
""" output will look as follows. Either the number (as int) or name (as str) can be used as identifier parameter
-1 - list
0 - mandelbrot
1 - mandelbar
.
.
.
11 - perpendicular_buffalo
"""
f = ComplexFractal() # set up a mandelbrot with default parameters
f.draw() # create the image
#rgb_phases used for all parameter images
phases = [0.4621369927925133,0.5109418659399724,0.5222266582635113]
see Fractal Types for how to retrieve a list of possible identifiers. The integer and string are both valid inputs.
number of pixels in the horizontal dimension of the output image.
aspect ratio of the output image. Input as type str in the form "W:H". Defaults to "16:9" (1920x1080), another common aspect ration is "21:9" (3440x1440).
ComplexFractal(aspect_ratio="16:9", rgb_phases=phases,
filename="aspect_ratio_16-9").draw()
ComplexFractal(aspect_ratio="21:9", rgb_phases=phases,
filename="aspect_ratio_21-9").draw()
the number of iterations before the colormap cycles back to the start. Smaller values yield faster color transitions.
ComplexFractal(cycle_count=16, rgb_phases=phases,
filename="cycle_count_16").draw()
ComplexFractal(cycle_count=32, rgb_phases=phases,
filename="cycle_count_32").draw()
ComplexFractal(cycle_count=64, rgb_phases=phases,
filename="cycle_count_64").draw()
scale the image dimensions by a factor of oversample. The image is then downscaled to the desired size by averaging oversample*oversample grids of pixels. Creates a cleaner image, but large oversample values can greatly increase computation times. Value must be greater than or equal to 1.
ComplexFractal(oversample=1, rgb_phases=phases,
filename="oversample_1").draw()
ComplexFractal(oversample=4, rgb_phases=phases,
filename="oversample_4").draw()
the real value to focus on or to zoom in on. Defaults to the center of the set.
the imaginary value to focus on or to zoom in on. Defaults to the center of the set.
the depth of the zoom. Value should be greater than or equal to 1. Defaults to 1.
phases used to create cyclic color map. Each value should be in the range [0.0, 1.0].
# Can preview colormaps using custom values with...
ColorMap(rgb_phases=[0.0, 0.8, 0.15]).preview_colormap()
# Or preview random colormaps with...
ColorMap(random_phases=True).preview_colormap() # random values generated are output to console
Whether random rgb phases should be used. Will always overide any values passed to rgb_phases if True. Defaults to False.
maximum number of iterations until a point that doesn't escape is considered part of the set. Deeper zoom levels require higher iter_max values.
how dense the stripes are in the final image.
ComplexFractal(stripe_density=0, rgb_phases=phases,
filename="stripe_density_0").draw()
ComplexFractal(stripe_density=2, rgb_phases=phases,
filename="stripe_density_2").draw()
ComplexFractal(stripe_density=6, rgb_phases=phases,
filename="stripe_density_6").draw()
the weight of historical values kept between iterations. Value should be in the range [0.0, 1.0]
ComplexFractal(stripe_memory=0.0, rgb_phases=phases,
filename="stripe_memory_0.0").draw()
ComplexFractal(stripe_memory=0.4, rgb_phases=phases,
filename="stripe_memory_0.4").draw()
ComplexFractal(stripe_memory=0.9, rgb_phases=phases,
filename="stripe_memory_0.9").draw()
how strong of a showing the stripes make in the final image, value in [0.1, 1.0].
ComplexFractal(blend_factor=0.33, rgb_phases=phases,
filename="blend_factor_0.33").draw()
ComplexFractal(blend_factor=0.66, rgb_phases=phases,
filename="blend_factor_0.66").draw()
ComplexFractal(blend_factor=1.0, rgb_phases=phases,
filename="blend_factor_1.0").draw()
Compute with GPU or with CPU. True will render using the GPU. Defaults to False. GPU will render the image significantly faster than CPU but requires the CUDA toolkit to be installed. Details on how to install it to work with Numba can be found here.
The name to be assigned to the output image. Defaults to the stringed version of the identifier.
the initial zoom level. Should be greater than or equal to 1.
the target zoom level to be reached in the final frame. Must be greater than start value.
the speed at which the zoom level approaches the end value. Must be strictly greater than 1.
- todo create example images/gifs/mp4s