Fracture fractale

branches fractales

mandelbrot

from PIL import Image

xa = -1.2
xb = -0.8
ya = 0.1
yb = 0.5
size_x = 600
size_y = 600
max_iteration = 256

image = Image.new(« RGB », (size_x, size_y))
mx = image.load()

lutx = [j * (xb-xa) / (size_x – 1) + xa for j in xrange(size_x)]

for y in xrange(size_y):
    cy = y * (yb – ya) / (size_y – 1)  + ya
    for x in xrange(size_x):
        c = complex(lutx[x], cy)
        z = 0
        for i in xrange(max_iteration):
            if abs(z) > 2.0: break
            z = z * z + c
        r = g = b = i % 255
        mx[x, y] =  r,g,b

image.save(« mandelbrot.png », « PNG »)