This is a simple python project to render lyapunov fractals. It relies on numba cuda kernels for relatively fast fractal generation.
- the numba package with cuda.
- numpy, pygame and pillow, that you can install with
pip install numpy pygame pillow
and that's it!
Running the file generate_fractal_image.py
creates an image of a fractal and displays it to the screen.
Running the file generate_fractal_video.py
creates and stores a gif cycling through slices of a 3D lyapunov fractal in the
Running the file fractal_zoom.py
opens a pygame window with a fractal:
- Press the
left mouse button
to zoom - Press the
right mouse button
to dezoom - Press
tab
to cycle through the$z$ values of the fractal - Press
space
to show the current coordinates. - Press
s
to generate a higher resolution image of the current fractal, and presss
again to save the image. - Press
c
to cycle the pattern.
The main class is ComputeFractals
. Its parameters are the following:
x_min
,x_max
,y_min
,y_max
,z_min
,z_max
define the region in which fractals will be computed. These values need to be between 0 and 4.size
: the size of the generated images in pixels.colors
: a list of hex colorscolor_resolution
: how many different shades of the color listself.COLORS
are used.pattern
: a string of "x", "y", and "z". The pattern defines which fractal is generated.num_iter
: defines at which precision the pixel values are computed.
These parameters can be modified after the class construction by accessing them directly, except for:
- num_iter which can not be changed.
- the
$x$ and$y$ boundaries, that you can change with theset_region
method. - the pattern, that you can change with the
set_pattern
method.
The main method of ComputeFractals
is compute_fractal(z)
, which computes
a slice of a 3D lyapunov fractal at a given
The class FractalZoom
with the run
method creates a pygame window and handles the zoom logic.