+ for (i = 0; i < max; i++)
+ {
+ int x, y, x2, y2;
+ if (lines[i] < height)
+ x = 0, y = lines[i], x2 = width, y2 = y;
+ else
+ x = lines[i]-height, y = 0, x2 = x, y2 = height;
+
+ if (flip_x)
+ x = width-x, x2 = width-x2;
+ if (flip_y)
+ y = height-y, y2 = height-y2;
+
+ XDrawLine (dpy, window, gc, x, y, x2, y2);
+ XSync (dpy, False);
+ if (delay > 0 && ((i % granularity) == 0))
+ usleep (delay*granularity);
+ }
+ free(lines);
+}
+
+
+
+static void
+circle_wipe (Display *dpy, Window window, GC gc,
+ int width, int height, int delay, int granularity)
+{
+ int full = 360 * 64;
+ int inc = full / 64;
+ int start = random() % full;
+ int rad = (width > height ? width : height);
+ int i;
+ if (random() & 1)
+ inc = -inc;
+ for (i = (inc > 0 ? 0 : full);
+ (inc > 0 ? i < full : i > 0);
+ i += inc)
+ {
+ XFillArc(dpy, window, gc,
+ (width/2)-rad, (height/2)-rad, rad*2, rad*2,
+ (i+start) % full, inc);
+ XFlush (dpy);
+ usleep (delay*granularity);
+ }
+}
+
+
+static void
+three_circle_wipe (Display *dpy, Window window, GC gc,
+ int width, int height, int delay, int granularity)
+{
+ int i;
+ int full = 360 * 64;
+ int q = full / 6;
+ int q2 = q * 2;
+ int inc = full / 240;
+ int start = random() % q;
+ int rad = (width > height ? width : height);
+
+ for (i = 0; i < q; i += inc)
+ {
+ XFillArc(dpy, window, gc, (width/2)-rad, (height/2)-rad, rad*2, rad*2,
+ (start+i) % full, inc);
+ XFillArc(dpy, window, gc, (width/2)-rad, (height/2)-rad, rad*2, rad*2,
+ (start-i) % full, -inc);
+
+ XFillArc(dpy, window, gc, (width/2)-rad, (height/2)-rad, rad*2, rad*2,
+ (start+q2+i) % full, inc);
+ XFillArc(dpy, window, gc, (width/2)-rad, (height/2)-rad, rad*2, rad*2,
+ (start+q2-i) % full, -inc);
+
+ XFillArc(dpy, window, gc, (width/2)-rad, (height/2)-rad, rad*2, rad*2,
+ (start+q2+q2+i) % full, inc);
+ XFillArc(dpy, window, gc, (width/2)-rad, (height/2)-rad, rad*2, rad*2,
+ (start+q2+q2-i) % full, -inc);
+
+ XSync (dpy, False);
+ usleep (delay*granularity);
+ }
+}
+
+
+static void
+squaretate (Display *dpy, Window window, GC gc,
+ int width, int height, int delay, int granularity)
+{
+ int steps = (((width > height ? width : width) * 2) / granularity);
+ int i;
+ Bool flip = random() & 1;
+
+#define DRAW() \
+ if (flip) { \
+ points[0].x = width-points[0].x; \
+ points[1].x = width-points[1].x; \
+ points[2].x = width-points[2].x; } \
+ XFillPolygon (dpy, window, gc, points, 3, Convex, CoordModeOrigin)
+
+ for (i = 0; i < steps; i++)
+ {
+ XPoint points [3];
+ points[0].x = 0;
+ points[0].y = 0;
+ points[1].x = width;
+ points[1].y = 0;
+ points[2].x = 0;
+ points[2].y = points[0].y + ((i * height) / steps);
+ DRAW();
+
+ points[0].x = 0;
+ points[0].y = 0;
+ points[1].x = 0;
+ points[1].y = height;
+ points[2].x = ((i * width) / steps);
+ points[2].y = height;
+ DRAW();
+
+ points[0].x = width;
+ points[0].y = height;
+ points[1].x = 0;
+ points[1].y = height;
+ points[2].x = width;
+ points[2].y = height - ((i * height) / steps);
+ DRAW();
+
+ points[0].x = width;
+ points[0].y = height;
+ points[1].x = width;
+ points[1].y = 0;
+ points[2].x = width - ((i * width) / steps);
+ points[2].y = 0;
+ DRAW();
+
+ XSync (dpy, True);
+ if (delay > 0)
+ usleep (delay * granularity);
+ }
+#undef DRAW
+}
+
+
+
+
+static Eraser erasers[] = {
+ random_lines,
+ venetian,
+ triple_wipe,
+ quad_wipe,
+ circle_wipe,
+ three_circle_wipe,
+ squaretate,
+};
+
+
+void
+erase_window(Display *dpy, Window window, GC gc,
+ int width, int height, int mode, int delay)
+{
+ int granularity = 25;
+
+ if (mode < 0 || mode >= countof(erasers))
+ mode = random() % countof(erasers);
+ (*(erasers[mode])) (dpy, window, gc, width, height, delay, granularity);