Skip to content

jepebe/fractal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fractal

This is a fractal renderer implemented in Python using the pixel fiddling tools provided by pxng. The Python solution is extremely slow so a binding to a Rust version of the calculation has been integrated. This improves the rendering time approximately 100 times. An additional rendering technique is also available, implemented with OpenGL Shaders, this one is at least 20 times faster than the Rust implementation.

Screenshot of a fractal

Building

Rust needs to be installed and a fairly new version of Python 3. Clone the repository and run the follow commands.

pip install pxng
make release

make release runs cargo build and copies the resulting dynamic library file into the Python package.

Running

From the command line run the application by calling python fractal.py. Screenshot of a fractal

The application will start in Rust mode and show the Mandelbrot fractal. Press 2 to switch to calculating the fractal using Python. Pressing 3 uses GLSL shaders to render the fractal (this requires OpenGL version 4 support). Press 1 to get back to Rust.

Point the mouse at any point and scroll your mouse wheel to zoom into (or out of) the fractal. You can also use z and x for this. Hold the left mouse button and drag the mouse to pan around. Press j and i to decrease or increase the number of iterations. As you zoom in it is necessary to increase the number of iterations. Reset to the initial view by pressing space. Press t to print the current view to the terminal.

Credits

  • OneLoneCoder and his YouTube movies (especially the one about fractals).
  • Pål Grønås Drange for the terminal visualization

About

Fractals all the way down

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published