All Projects → pysrc → fractal

pysrc / fractal

Licence: MIT License
Draw fractal image by python.

Programming Languages

python
139335 projects - #7 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to fractal

xirho
xirho is a simple generalized iterated function system plotter.
Stars: ✭ 16 (-40.74%)
Mutual labels:  fractal, ifs
Fractal-Inferno
An Online Fractal Flame Generator.
Stars: ✭ 41 (+51.85%)
Mutual labels:  fractal, ifs
ElectricSheep WebGL
WebGL Electric Sheep Renderer
Stars: ✭ 14 (-48.15%)
Mutual labels:  fractal, ifs
iterated-function-systems
Iterated Function Systems fractals with OCaml.
Stars: ✭ 33 (+22.22%)
Mutual labels:  fractal
cas
Cellular Automata Simulator
Stars: ✭ 22 (-18.52%)
Mutual labels:  fractal
immerx-state
Reactive, fractal and no-nonsense state management with Immer
Stars: ✭ 19 (-29.63%)
Mutual labels:  fractal
laravel-datatables-fractal
Laravel DataTables Fractal Plugin.
Stars: ✭ 94 (+248.15%)
Mutual labels:  fractal
fractal-starter-kit
Starter kit for Fractal with SCSS, Webpack, XO, sass-lint and Gulp
Stars: ✭ 22 (-18.52%)
Mutual labels:  fractal
blender-osl-shader
procedural textures for blender (open shading language)
Stars: ✭ 22 (-18.52%)
Mutual labels:  fractal
dva-boot
🌱 使用CRA(create-react-app v2) 构建的react dva 2 脚手架 支持动态路由、接口数据模拟、按功能分层、并且包含诸多实用的小组件
Stars: ✭ 79 (+192.59%)
Mutual labels:  fractal
Algorithms
Free hands-on course with the implementation (in Python) and description of several computational, mathematical and statistical algorithms.
Stars: ✭ 117 (+333.33%)
Mutual labels:  fractal
pycontextfree
Pythonic generative art tool
Stars: ✭ 32 (+18.52%)
Mutual labels:  fractal
aframe-lsystem-component
L-System/LSystem component for A-Frame to draw 3D turtle graphics. Using Lindenmayer as backend.
Stars: ✭ 33 (+22.22%)
Mutual labels:  fractal
fraqtive
Generator of the Mandelbrot family fractals.
Stars: ✭ 21 (-22.22%)
Mutual labels:  fractal
gpu mandelbrot
Interactive Mandelbrot set on GPU with Python
Stars: ✭ 33 (+22.22%)
Mutual labels:  fractal
gis-snippets
Some code snippets for GIS tasks
Stars: ✭ 45 (+66.67%)
Mutual labels:  fractal
Fatou.jl
Fatou sets in Julia (Fractals, Newton basins, Mandelbrot)
Stars: ✭ 92 (+240.74%)
Mutual labels:  julia-sets
restate
A redux fractal state library 🕷
Stars: ✭ 55 (+103.7%)
Mutual labels:  fractal
FractalBlizzard2
分形风暴2,用来绘制精美的自定义分形图片.
Stars: ✭ 45 (+66.67%)
Mutual labels:  fractal
fractal-react-adapter
Use React as the template engine for Fractal (http://fractal.build) components.
Stars: ✭ 21 (-22.22%)
Mutual labels:  fractal

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:
        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()

# 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

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()

Julia

from fractal import Julia
ju = Julia([500, 500])
ju.setC(0 - 1j)
ju.doJulia(500)
ju.wait()

-1.25 + 0j

-0.605-0.45j

Mandelbrot

from fractal import Mandelbrot
man = Mandelbrot([500, 500])
man.setRange(5, 5)
man.doMandelbrot(200)
man.wait()

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].