This method uses inverse IFS transformations and it does not use a random number generator.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38  | # Dragon Fractal using Iteration method
# FB - 20120106
from collections import deque
from PIL import Image
imgx = 512
imgy = 512
image = Image.new("RGB", (imgx, imgy))
maxIt = 16 # max iterations allowed
xa = -1.0 / 3
xb = 7.0 / 6
ya = -1.0 / 3
yb = 2.0 / 3
for ky in range(imgy):
    for kx in range(imgx):
        x = float(kx) / (imgx - 1) * (xb - xa) + xa
        y = float(ky) / (imgy - 1) * (yb - ya) + ya
        queue = deque([])
        queue.append((x, y, 0))
        while len(queue) > 0:
            (x, y, i) = queue.popleft()
            # try 1. transformation
            xnew = x + y
            ynew = y - x
            if xnew >= xa and xnew <= xb and ynew >= ya and ynew <= yb:
                if i + 1 == maxIt: break
                queue.append((xnew, ynew, i + 1))
            # try 2. transformation                
            xnew = 1.0 - x + y
            ynew = 1.0 - x - y
            if xnew >= xa and xnew <= xb and ynew >= ya and ynew <= yb:
                if i + 1 == maxIt: break
                queue.append((xnew, ynew, i + 1))
        image.putpixel((kx, ky), (i % 8 * 32, 255 - i % 16 * 16, i % 16 * 16))
image.save("DragonFractal_Iter.png", "PNG")
 | 
Download
Copy to clipboard
And this is the C fractal using iteration method:
What I mean by inverse IFS transformations is this: Take any IFS fractal transformation. Assume x and y are unknown and new x and new y are known and solve the equation system. Later use the new inverse IFS equations w/ this algorithm. You will get the same fractal w/o using a random number generator, unlike IFS.
I find it interesting that using IFS or iteration method, equations for dragon and C fractals are similar but using L-System they are quite different.