Skip to content

pysrc/fractal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Draw Fractal Image By Python

install

pip install fractal

Or download the package

python setup.py install

If you want to speed up the calculation of Julia Set or Mandelbort Set, you can use the fractension module in C_Extension dir. But you must build the fractension module by yourself , the more details in here.

Examples

L-System

from fractal import Pen
from math import sqrt
p = Pen([350, 270])
p.setPoint([140, 60])
p.setWidth(1)
p.doD0L(omega="L", P={"L": "L+R", "R": "L-R"},
              delta=90, times=15, length=200, rate=sqrt(2))
p.wait()

from fractal import Pen

p = Pen([500, 500], title="Window")
p.setPoint([495, 495])
p.setAngle(90)
p.doD0L(omega="f+f+f+f", P={"f": "ff+f--f+f"},
        delta=90, times=5, length=490, rate=3)
p.wait()

from fractal import Pen
p = Pen([420,420])
p.setPoint([10,10])
p.doD0L(omega = "L", P = {"L": "LFRFL-FF-RFLFR+FF+LFRFL", "R": "RFLFR+FF+LFRFL-FF-RFLFR"}, delta =  90, times = 4, length = 200 , rate = 3)
p.wait()

from fractal import Pen
p = Pen([400, 470])
p.setAngle(90)
p.setPoint([200,470])
p.doD0L(omega = "f", P = {"f": "h[-f][+f]hf", "h": "hh"}, delta = 25.7, times = 7, length = 400, rate = 2.17)
p.wait()

from fractal import Pen
p = Pen([400, 470])
p.setAngle(90)
p.setPoint([170, 470])
p.doD0L(omega="f", P={"f": "h+[[f]-f]-h[-hf]+f", "h": "hh"},
        delta=22.5, times=6, length=400, rate=2.3)
p.wait()

IFS

from fractal import IFS
from random import random

def ifsp(x, y):
    p = random()
    if p < 0.01:
        return (0, 0.16 * y)
    elif p < 0.07: