- int inclear, i;
- int delay= get_integer_resource("delay", "Integer");
- init_squiral(dpy, window);
- cov=0; inclear=height;
- while(1) {
- if(inclear<height) {
- XDrawLine(dpy, window, erase_gc, 0, inclear, width-1, inclear);
- memset(&fill[inclear*width], 0, sizeof(int)*width);
- XDrawLine(dpy, window, erase_gc, 0, height-inclear-1, width-1,
- height-inclear-1);
- memset(&fill[(height-inclear-1)*width], 0, sizeof(int)*width);
- inclear++;
- XDrawLine(dpy, window, erase_gc, 0, inclear, width-1, inclear);
- memset(&fill[inclear*width], 0, sizeof(int)*width);
- XDrawLine(dpy, window, erase_gc, 0, height-inclear-1, width-1,
- height-inclear-1);
- memset(&fill[(height-inclear-1)*width], 0, sizeof(int)*width);
- inclear++;
- if(inclear>height/2) inclear=height;
- }
- else if(cov>(frac*width*height)) {
- inclear=0;
- cov=0;
- }
- for(i=0;i<count;i++) do_worm(dpy, window, &worms[i]);
- screenhack_handle_events(dpy);
- usleep(delay);
- }
+ struct state *st = (struct state *) closure;
+ int i;
+
+ if(st->inclear<st->height) {
+ XDrawLine(st->dpy, st->window, st->erase_gc, 0, st->inclear, st->width-1, st->inclear);
+ memset(&st->fill[st->inclear*st->width], 0, sizeof(int)*st->width);
+ XDrawLine(st->dpy, st->window, st->erase_gc, 0, st->height-st->inclear-1, st->width-1,
+ st->height-st->inclear-1);
+ memset(&st->fill[(st->height-st->inclear-1)*st->width], 0, sizeof(int)*st->width);
+ st->inclear++;
+ XDrawLine(st->dpy, st->window, st->erase_gc, 0, st->inclear, st->width-1, st->inclear);
+ memset(&st->fill[st->inclear*st->width], 0, sizeof(int)*st->width);
+ XDrawLine(st->dpy, st->window, st->erase_gc, 0, st->height-st->inclear-1, st->width-1,
+ st->height-st->inclear-1);
+ memset(&st->fill[(st->height-st->inclear-1)*st->width], 0, sizeof(int)*st->width);
+ st->inclear++;
+ if(st->inclear>st->height/2) st->inclear=st->height;
+ }
+ else if(st->cov>(st->frac*st->width*st->height)) {
+ st->inclear=0;
+ st->cov=0;
+ }
+ for(i=0;i<st->count;i++) do_worm(st, &st->worms[i]);
+ return st->delay;