Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Victor Widell, posted on January 30, 2005

Image Description, by Victor Widell

This is a fractal I came up with when I was bored.

I call it a flood fractal, since it is basically a flood fill where the direction order of recursion is changed randomly. The pixels are colored with a gradient based on the recursion depth. As far as I know, this has not been done before.

It was very simple to code, but the extreme recursion depth would kill the stack size of a normal recursive function. Luckily, I learned to implement my own stack/recursion mechanism in university. (One of the few really useful classes.)

Implemented with TinyPTC and STL.

Image of the Day Gallery


Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
Jari Komppa

January 30, 2005, 12:33 PM

At a glance it looks like a chaos zoomer =)

Victor Widell

January 30, 2005, 02:47 PM

I googled for "chaos zoomer" and a few variations of the same string.

It seems to be used to meassure graphics performance, but I could find no image or descripting of the algorithm. Could you explain it?


January 30, 2005, 03:04 PM

This has certainly been done before. You can see zoomers like this often referred as chaos zoomers in old Amiga demos. Plotted and rotated realtime with copper.


January 30, 2005, 04:56 PM

Ah did you think it was used to measure graphics performance because of this link: It's not used specifically for measuring graphics performance, it's just that it was used in the Final Reality benchmark software which was written by demo sceners :)

Cool nonetheless!



January 31, 2005, 04:00 AM

this is definately cool (although i don't 100% understand the description of the algorithm, some pseudo-code would be cool!), i like such stuff. btw, could be used for nice texture-generation in intros too.


January 31, 2005, 05:01 AM

With a slight variation this has been described by famous J. H. Conway some 30 years ago.

Obviously he didn't use gradients at that time. He used a pattern filling algorithm that varied with the direction, to make the areas look like mazes or biological structures.

Also he wanted to simulate an evolutionary process, so once the areas and borders had developed, they would start to fight against the neighboring areas of different color, growing and shrinking until all but one dominant area had died.

I might still have some Turbo Pascal code for that.

With a more comforting color scheme I should like to use that one for my desktop.

Victor Widell

January 31, 2005, 08:04 AM

"some pseudo-code would be cool!"


  2. void FloodFractal(int x, int y, int Depth){
  3.   // Stop recursing if pixel is invalid or allready filled.
  4.   if(x<0 || x>X_MAX || y<0 || y>Y_MAX || Image[x][y]!=COLOR_KEY) return;
  6.   // Plot pixel.
  7.   Image[x][y] = Gradient(Depth);
  9.   // Directions for Down, Right, Up and left, respectively.
  10.   static int Dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
  12.   // Shuffle the array randomly.
  14.   // Recurse in all 4 directions.
  15.   for(int i=0; i<4; i++)
  16.     FloodFractal(x+Dir[i][0], y+Dir[i][1], Depth+1);
  17. }

Note that this code won't work even if you implement Shuffle() and Gradient(), since the default stack can't handle extremely deep recursion. (The image used over 50000 recursions deep.)

"this has been described by famous J. H. Conway some 30 years ago."

Is it like the "Ants" fractal in Fractint? (Some kind of celluar automata, like "Life".)


January 31, 2005, 10:01 AM

No, it's not really like ants. But it's a cellular automat, yes. The screen gets filled with random colors and rules of dominance are applied to each cell each iteration. Areas appear that look exactly like your image, and at the borders they fight each other.


January 31, 2005, 01:18 PM

ermn, if you use

static int

you overwrite yout direction-lookup all the time, in each subcall!? is that really what you wanted?


January 31, 2005, 01:28 PM

I donít know but it seam right to me. Afterwards he is shuffling the array anyway and then he uses the values as parameters. Having it static and using it in a recursion (huge recursion depth) it is probably better because of limited memory.


January 31, 2005, 01:47 PM

well, yes, it works. but imho it makes the for-loop pretty useless (one call instead of 4 would be enough, because things are shuffled in the next iteration anyways) would result in a ~similar result. or did i miss something? =)

Victor Widell

February 04, 2005, 09:28 AM

Yes, you are right. My mistake.

I the real implementation I push all 4 recursions onto the stack before I start executing the first one, thus I don't have to reinitialize the directions every loop. Obviously, the static keyword doesn't make sense in the context of my pseudo code.

This thread contains 12 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.