Skip to the content.

pyfractal

A simple gui based self-similar fractal generator

Introduction

This project is aimed to provide a simple gui for drawing fractals so that anyone enthusiastic enough can give them a try.

Table of contents

I was exploring an awesome site which taught me how a turtle would draw amazing fractal curves. Perhaps I made a small script which would draw fractals pretty neatly but it had two issues :-

Features

Samples/Download

A few of the fractal images are available to download/view in fractal_images in png and svg formats

NOTE: Pngs may get HUGE in size, deter from using them

Setup

pip3 install pyfractal

or

pip install pyfractal

should do the job depending on the distribution

Having issues installing? Feel free to report issue or simply clone the repository and run main.py

Usage

import pyfractal  #import the module
pyfractal.GUI().run()  #to run the main gui

A GUI should pop up Main GUI

Curve parameter input

Pressing on the plus and minus buttons adds and removes entires for rule input

Saving curve parameters

Press the Save Parameters button to save the parameters, a dialog box should appear asking for the name of the file to save the parameters are stored in a json file

Loading curve parameters

Press the Load Parameters button to load the parameters, a dialog box should appear asking for the name of the file. If the file is correctly formatted, you should see the parameters loaded onto the screen and list of rules added to the list.


NOTE The rules are appended to the list of pre-written rules (this is a design choice, not a bug) , clear the pre-existing rules by repeatedly pressing minus button then loading from file.


Example Fractal

Drawing fractals

Feed in/ load the rules, you will see the preview of base fractal image on the smaller canvas.

Enter your desired Recursion Depth and you will see your fractal drawn on the canvas Pan/scale/scroll in the canvas according to your viewing preferences


NOTE The rules/preview-canvas is update only once plus or minus button is pressed.

Start drawing fractal from a smaller recursion-depth. The size of fractal is exponential in the recursion depth. It is recommended that you keep Recursion depth to a single digit integer.


Libraries Used

The project is almost built entirely on tkinter Besides using Pillow and canvasvg to save the canvas

Feedback

Feel free to contribute/clone/Issue or Contact me

TODO

This is probably a VERY long list but here are key TODO’s :-

Sources

The following links are pretty useful and helpful in learning more about fractals

Contact