+ int delay = st->subdelay;
+ int erase_delay = 10000;
+ int ii;
+
+ if (st->eraser) {
+ st->eraser = erase_window (dpy, window, st->eraser);
+ if (st->eraser)
+ delay = erase_delay;
+ goto END;
+ }
+
+ switch (st->dstate)
+ {
+ case LINGER:
+ delay = st->sleep_time * 1000000;
+ st->dstate = ERASE;
+ break;
+
+ case ERASE:
+ st->eraser = erase_window (dpy, window, st->eraser);
+ delay = erase_delay;
+ if (free_color) XFreeColors (dpy, st->cmap, &color.pixel, 1, 0);
+ st->dstate = (random() & 1) ? HELIX : TRIG;
+ break;
+
+ case DRAW_HELIX:
+ for (ii = 0; ii < 10; ii++) {
+ helix (dpy, window, st);
+ if (st->dstate != DRAW_HELIX)
+ break;
+ }
+ break;
+
+ case DRAW_TRIG:
+ for (ii = 0; ii < 5; ii++) {
+ trig (dpy, window, st);
+ if (st->dstate != DRAW_TRIG)
+ break;
+ }
+ break;
+
+ case HELIX:
+ random_helix (dpy, window, st, &color, &free_color);
+ st->dstate = DRAW_HELIX;
+ break;
+
+ case TRIG:
+ random_trig(dpy, window, st, &color, &free_color);
+ st->dstate = DRAW_TRIG;
+ break;
+
+ default:
+ abort();
+ }