Path: unixg.ubc.ca!cs.ubc.ca!utcsri!utnut!torn!spool.mu.edu!sol.ctr.columbia.edu!math.ohio-state.edu!usc!rutgers!rochester!rocksanne!spear.wrc.xerox.com!fleck From: fleck@spear.wrc.xerox.com (Pat Fleckenstein) Newsgroups: alt.binaries.pictures.fractals Subject: Fractals of random generation... Message-ID: <1993Aug4.201938.28288@spectrum.xerox.com> Date: 4 Aug 93 20:19:38 GMT Sender: news@spectrum.xerox.com Organization: The World At Your Doorstep Lines: 143 Just for grins, I wrote a little program to make fractals of random generation. The basic algorithm here used is this... For the file RANGE-OFFSET-n.gif 128 points were chosen to be fixed in 2-space. Then, a point (x,y) was chosen from the same area as the original 128. One of the original 128 is chosen as a seed for this point. Once the seed has been chosen, the point is modified so that it becomes the average of its current position and the position of one of RANGE-points in then range seed+OFFSET to seed+OFFSET+RANGE of the fixed 128 points. The 128-point range wraps around. The seed then becomes the fixed point averaged with and the process is repeated. The X-windows source code follows. This code performs this loop 4098 times in parallel to reduce X-overhead. ========================================================================= /* ** I gave it to you. Play with it. */ #include #include Display *dpy; Window win; Window root; int screen; GC gc; unsigned long mask; XGCValues xgcv; XEvent ev; unsigned long black; unsigned long white; #define WIDTH 1024 #define HEIGHT 512 #define FIXED 128 #define RANGE 3 #define OFFSET 1 #define NUM_PTS FIXED+4096 static XPoint pts[NUM_PTS]; static int last[NUM_PTS]; void InitializePoints( void ) { register int i; srandom(time(NULL)); pts[0].x = random()%WIDTH; pts[0].y = random()%HEIGHT; /* ** Pick fixed points sorta near each other... */ for (i=1;i WIDTH)); do { pts[i].y = pts[i-1].y + (random()%(HEIGHT/2)) - HEIGHT/4; } while ((pts[i].y < 0) || (pts[i].y > HEIGHT)); } /* ** start extra points anywhere... */ for (i=FIXED;i