...colors make the world beautiful...

Thursday, September 21, 2006

Plasma Fractals

WHAT ARE THEY?

Plasma fractals are perhaps the most useful fractals there are. Unlike most other fractals, they have a random element in them, which gives them Brownian self-similarity. To create a plasma fractal on a rectangular piece of plane, you do the following:

1. Randomly pick values for the corners of the rectangle.
2. Calculate the value for the center of the rectangle by taking the average of the corners and adding a random number multiplied by a preset roughness parameter.
3. Calculate the midpoints of the rectangles� sides by taking averages of the two nearest corners and adding a random number multiplied by the roughness parameter.
4. You now have four smaller rectangles. Do steps 2-4 for each of them.

Here is the basic algorithm of drawing plasmas:

Constants used:

number_of_colors: number of colors available in the computer language you�re using
size: size of the fractal; must be a power of 2
roughness: higher values make the fractal more fragmented

� randomly choose the rectangle�s corners
array(0, 0) = RND * number_of_colors
array(size, 0) = RND * number_of_colors
array(0, size) = RND * number_of_colors
array(size, size) = RND * number_of_colors
� go through the array, decreasing the interval size every time
FOR p = LOG(size) / LOG(2) TO 0 STEP -1
FOR x = 0 TO size STEP 2 ^ p
FOR y = 0 TO size STEP 2 ^ p
IF x MOD 2 ^ (p + 1) = 0 AND y MOD 2 ^ (p + 1) = 0 GOTO nxt
IF x MOD 2 ^ (p + 1) = 0 THEN
average = (array(x, y + 2 ^ p) + array(x, y - 2 ^ p)) / 2
color = average + roughness * (RND - .5)
array(x, y) = color: GOTO nxt
END IF
IF y MOD 2 ^ (p + 1) = 0 THEN
average = (array(x + 2 ^ p, y) + array(x - 2 ^ p, y)) / 2
color = average + roughness * (RND - .5)
array(x, y) = color: GOTO nxt
END IF
IF x MOD 2 ^ (p + 1) > 0 AND y MOD 2 ^ (p + 1) > 0 THEN
v1 = array(x + 2 ^ p, y + 2 ^ p)
v2 = array(x + 2 ^ p, x - 2 ^ p)
v3 = array(x - 2 ^ p, x + 2 ^ p)
v4 = array(x - 2 ^ p, y - 2 ^ p)
average = (v1 + v2 + v3 + v4) / 4
color = average + roughness * (RND - .5)
array(x, y) = color: GOTO nxt
END IF
nxt:
NEXT y
NEXT x
NEXT p
� go through the array, plotting the points
FOR x = 0 TO size
FOR y = 0 TO size
PSET (x, y), array(x, y)
NEXT y
NEXT x

I don't know what it is. But, I think it's about colors. You can go to this blog
http://zet-fractalia.blogspot.com/

0 Comments:

Post a Comment

<< Home