# Box IFS from fractal import IFS from random import randint def ifsp(x, y): p = randint(1, 5) if p == 1: return (x / 3, y / 3) elif p == 2: return (x / 3 + 2 / 3, y / 3) elif p == 3: return (x / 3 + 1 / 3, y / 3 + 1 / 3) elif p == 4: return (x / 3, y / 3 + 2 / 3) else: return (x / 3 + 2 / 3, y / 3 + 2 / 3) ob = IFS([500, 500], title="Box") ob.setPx(490, 5, 5) ob.setIfsp(ifsp) ob.doIFS(200000) ob.wait()
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: if random() > 0.5: return (0.21 * x - 0.25 * y, 0.25 * x + 0.21 * y + 0.44) else: return (-0.2 * x + 0.26 * y, 0.23 * x + 0.22 * y + 0.6) else: return (0.85 * x + 0.1 * y, -0.05 * x + 0.85 * y + 0.6) ob = IFS([400, 500], title="Leaf") ob.setPx(100, 100, 100) ob.setIfsp(ifsp) ob.doIFS(200000) ob.wait()
from fractal import IFS ifscode = [[0.879, 0.054, -0.051, 0.878, 0.077, 0.123, 0.123], [0.1, -0.193, 0.285, 0.224, 0.174, 0.169, 0.169], [0.008, 0.135, 0, 0.204, 0.075, 0.074, 0.074], [0.402, 0.045, 0.016, -0.197, 0.111, 0.193, 0.193]] ifs = IFS([500, 500]) # ifs.setCoordinate() ifs.setPx(700, 0, 0) ifs.setIfsCode(ifscode) ifs.doIFS(200000) ifs.wait()
from fractal import IFS code = [[0.195, -0.488, 0.344, 0.443, 0.4431, 0.2452, 0.2], [0.462, 0.414, -0.252, 0.361, 0.2511, 0.5692, 0.2], [-0.637, 0, 0, 0.501, 0.8562, 0.2512, 0.2], [-0.035, 0.07, -0.469, 0.022, 0.4884, 0.5069, 0.2], [-0.058, -0.07, -0.453, -0.111, 0.5976, 0.0969, 0.2]] ifs = IFS([500, 500]) ifs.setCoordinate() ifs.setPx(500, 0, 0) ifs.setIfsCode(code) ifs.doIFS(200000) ifs.wait()
from fractal import IFS from fractal.ifs import getIfsCode ifscode = [ [0.27, 0.27, 0, 0, 1, 0, 1 / 9], [0.27, 0.27, 0, 0, 0.707, 0.707, 1 / 9], [0.27, 0.27, 0, 0, 0, 1, 1 / 9], [0.27, 0.27, 0, 0, -0.707, 0.707, 1 / 9], [0.27, 0.27, 0, 0, -1, 0, 1 / 9], [0.27, 0.27, 0, 0, -0.707, -0.707, 1 / 9], [0.27, 0.27, 0, 0, 0, -1, 1 / 9], [0.27, 0.27, 0, 0, 0.707, -0.707, 1 / 9], [0.5, 0.5, 22.5, 22.5, 0, 0, 1 / 9], ] ifs = IFS([500, 500]) # ifs.setCoordinate() ifs.setPx(100, 250, 250) ifs.setIfsCode(getIfsCode(ifscode)) ifs.doIFS(200000) ifs.wait()
# Sier三角变换 from fractal import IFS from random import randint def ifsp(x, y): p = randint(1, 3) if p == 1: return (0.5 * x, 0.5 * y) elif p == 2: return (0.5 * x + 0.5, 0.5 * y + 0.5) else: return (0.5 * x + 0.5, 0.5 * y) ob = IFS([460, 450], title="Sier") ob.setPx(400, 0, 10) ob.setIfsp(ifsp) ob.doIFS(200000) ob.wait()