}
+/* from Frederick Roeber <roeber@netscape.com> */
+static void
+fizzle (Display *dpy, Window window, GC gc,
+ int width, int height, int delay, int granularity)
+{
+ /* These dimensions must be prime numbers. They should be roughly the
+ square root of the width and height. */
+# define BX 31
+# define BY 31
+# define SIZE (BX*BY)
+
+ int array[SIZE];
+ int i, j;
+ XPoint *skews;
+ int nx, ny;
+
+ /* Distribute the numbers [0,SIZE) randomly in the array */
+ {
+ int indices[SIZE];
+
+ for( i = 0; i < SIZE; i++ ) {
+ array[i] = -1;
+ indices[i] = i;
+ }
+
+ for( i = 0; i < SIZE; i++ ) {
+ j = random()%(SIZE-i);
+ array[indices[j]] = i;
+ indices[j] = indices[SIZE-i-1];
+ }
+ }
+
+ /* nx, ny are the number of cells across and down, rounded up */
+ nx = width / BX + (0 == (width %BX) ? 0 : 1);
+ ny = height / BY + (0 == (height%BY) ? 0 : 1);
+ skews = (XPoint *)malloc(sizeof(XPoint) * (nx*ny));
+ if( (XPoint *)0 != skews ) {
+ for( i = 0; i < nx; i++ ) {
+ for( j = 0; j < ny; j++ ) {
+ skews[j * nx + i].x = random()%BX;
+ skews[j * nx + i].y = random()%BY;
+ }
+ }
+ }
+
+# define SKEWX(cx, cy) (((XPoint *)0 == skews)?0:skews[cy*nx + cx].x)
+# define SKEWY(cx, cy) (((XPoint *)0 == skews)?0:skews[cy*nx + cx].y)
+
+ for( i = 0; i < SIZE; i++ ) {
+ int x = array[i] % BX;
+ int y = array[i] / BX;
+
+ {
+ int iy, cy;
+ for( iy = 0, cy = 0; iy < height; iy += BY, cy++ ) {
+ int ix, cx;
+ for( ix = 0, cx = 0; ix < width; ix += BX, cx++ ) {
+ int xx = ix + (SKEWX(cx, cy) + x*((cx%(BX-1))+1))%BX;
+ int yy = iy + (SKEWY(cx, cy) + y*((cy%(BY-1))+1))%BY;
+ if (xx < width && yy < height)
+ XDrawPoint(dpy, window, gc, xx, yy);
+ }
+ }
+ }
+
+ if( (BX-1) == (i%BX) ) {
+ XSync (dpy, False);
+ usleep (delay*granularity);
+ }
+ }
+
+# undef SKEWX
+# undef SKEWY
+
+ if( (XPoint *)0 != skews ) {
+ free(skews);
+ }
+
+# undef BX
+# undef BY
+# undef SIZE
+}
+
+
+/* from Rick Campbell <rick@campbellcentral.org> */
+static void
+spiral (Display *display, Window window, GC context,
+ int width, int height, int delay, int granularity)
+{
+# define SPIRAL_ERASE_PI_2 (M_PI + M_PI)
+# define SPIRAL_ERASE_LOOP_COUNT (10)
+# define SPIRAL_ERASE_ARC_COUNT (360.0)
+# define SPIRAL_ERASE_ANGLE_INCREMENT (SPIRAL_ERASE_PI_2 / \
+SPIRAL_ERASE_ARC_COUNT)
+# define SPIRAL_ERASE_DELAY (0)
+
+ double angle;
+ int arc_limit;
+ int arc_max_limit;
+ int length_step;
+ XPoint points [3];
+
+ angle = 0.0;
+ arc_limit = 1;
+ arc_max_limit = (int) (ceil (sqrt ((width * width) + (height * height)))
+ / 2.0);
+ length_step = ((arc_max_limit + SPIRAL_ERASE_LOOP_COUNT - 1) /
+ SPIRAL_ERASE_LOOP_COUNT);
+ arc_max_limit += length_step;
+ points [0].x = width / 2;
+ points [0].y = height / 2;
+ points [1].x = points [0].x + length_step;
+ points [1].y = points [0].y;
+ points [2].x = points [1].x;
+ points [2].y = points [1].y;
+
+ for (arc_limit = length_step;
+ arc_limit < arc_max_limit;
+ arc_limit += length_step)
+ {
+ int arc_length = length_step;
+ int length_base = arc_limit;
+ for (angle = 0.0; angle < SPIRAL_ERASE_PI_2;
+ angle += SPIRAL_ERASE_ANGLE_INCREMENT)
+ {
+ arc_length = length_base + ((length_step * angle) /
+ SPIRAL_ERASE_PI_2);
+ points [1].x = points [2].x;
+ points [1].y = points [2].y;
+ points [2].x = points [0].x + (int)(cos (angle) * arc_length);
+ points [2].y = points [0].y + (int)(sin (angle) * arc_length);
+ XFillPolygon (display, window, context, points, 3, Convex,
+ CoordModeOrigin);
+# if (SPIRAL_ERASE_DELAY != 0)
+ usleep (SPIRAL_ERASE_DELAY);
+# endif /* (SPIRAL_ERASE_DELAY != 0) */
+ }
+ }
+# undef SPIRAL_ERASE_DELAY
+# undef SPIRAL_ERASE_ANGLE_INCREMENT
+# undef SPIRAL_ERASE_ARC_COUNT
+# undef SPIRAL_ERASE_LOOP_COUNT
+# undef SPIRAL_ERASE_PI_2
+}
+
+
+#undef MAX
+#undef MIN
+#define MAX(a,b) ((a)>(b)?(a):(b))
+#define MIN(a,b) ((a)<(b)?(a):(b))
+
+/* from David Bagley <bagleyd@tux.org> */
+static void
+random_squares(Display * dpy, Window window, GC gc,
+ int width, int height, int delay, int granularity)
+{
+ int randsize = MAX(1, MIN(width, height) / (16 + (random() % 32)));
+ int max = (height / randsize + 1) * (width / randsize + 1);
+ int *squares = (int *) calloc(max, sizeof (*squares));
+ int i;
+ int columns = width / randsize + 1; /* Add an extra for roundoff */
+
+ for (i = 0; i < max; i++)
+ squares[i] = i;
+
+ for (i = 0; i < max; i++)
+ {
+ int t, r;
+ t = squares[i];
+ r = random() % max;
+ squares[i] = squares[r];
+ squares[r] = t;
+ }
+
+ for (i = 0; i < max; i++)
+ {
+ XFillRectangle(dpy, window, gc,
+ (squares[i] % columns) * randsize,
+ (squares[i] / columns) * randsize,
+ randsize, randsize);
+
+ XSync(dpy, False);
+ if (delay > 0 && ((i % granularity) == 0))
+ usleep(delay * granularity);
+ }
+ free(squares);
+}
+
+/* I first saw something like this, albeit in reverse, in an early Tetris
+ implementation for the Mac.
+ -- Torbjörn Andersson <torbjorn@dev.eurotime.se>
+ */
+
+static void
+slide_lines (Display * dpy, Window window, GC gc, int width, int height,
+ int delay, int granularity)
+{
+ int slide_old_x, slide_new_x, clear_x;
+ int x, y, dx, dy;
+ /* This might need some tuning. The idea is to get sensible values no
+ matter what the size of the window.
+
+ Everything moves at constant speed. Should it accelerate instead? */
+
+ granularity *= 2;
+
+ dy = MAX (1, height / granularity);
+ dx = MAX (1, width / 100);
+
+ for (x = 0; x < width; x += dx)
+ {
+ for (y = 0; y < height; y += dy)
+ {
+ if ((y / dy) & 1)
+ {
+ slide_old_x = x;
+ slide_new_x = x + dx;
+ clear_x = x;
+ }
+ else
+ {
+ slide_old_x = dx;
+ slide_new_x = 0;
+ clear_x = width - x - dx;
+ }
+
+ XCopyArea (dpy, window, window, gc, slide_old_x, y, width - x - dx,
+ dy, slide_new_x, y);
+ XClearArea (dpy, window, clear_x, y, dx, dy, False);
+ }
+
+ XSync(dpy, False);
+ usleep(delay * 3);
+ }
+}
static Eraser erasers[] = {
random_lines,
circle_wipe,
three_circle_wipe,
squaretate,
+ fizzle,
+ random_squares,
+ spiral,
+ slide_lines,
};
0
};
-XrmOptionDescRec options [] = {0};
+XrmOptionDescRec options [] = {{0}};
int options_size = 0;
void