http://www.jwz.org/xscreensaver/xscreensaver-5.07.tar.gz
[xscreensaver] / hacks / coral.c
index b69f4361c2b34afd5c6f4079082d796e61fa5b00..7b4e482063e2419bda07b761199f3265c2de014e 100644 (file)
@@ -100,12 +100,15 @@ init_coral(struct state *st)
     st->colorsloth = st->nwalkers*2/st->ncolors;
     XSetForeground(st->dpy, st->draw_gc, st->colors[st->colorindex].pixel);
 
+    if ((st->width <= 2) || (st->height <= 2)) return;
+
     for( i = 0; i < seeds; i++ ) {
         int x, y;
+       int max_repeat = 10;
         do {
           x = 1 + random() % (st->width - 2);
           y = 1 + random() % (st->height - 2);
-        } while( getdot(x, y) );
+        } while( getdot(x, y) && max_repeat--);
 
         setdot((x-1), (y-1)); setdot(x, (y-1)); setdot((x+1), (y-1));
        setdot((x-1),  y   ); setdot(x,  y   ); setdot((x+1),  y   );
@@ -169,7 +172,8 @@ coral(struct state *st)
       st->nwalkers--;
       st->walkers[i].x = st->walkers[st->nwalkers].x;
       st->walkers[i].y = st->walkers[st->nwalkers].y;
-      if( 0 == (st->nwalkers%st->colorsloth) ) {
+      if( 0 == 
+         ((st->colorsloth ? st->nwalkers%st->colorsloth : 0)) ) {
         color = True;
       }
                  
@@ -278,6 +282,7 @@ coral_free (Display *dpy, Window window, void *closure)
 static const char *coral_defaults[] = {
   ".background:        black",
   ".foreground:        white",
+  "*fpsSolid:  true",
   "*density:   25",
   "*seeds:     20", /* too many for 640x480, too few for 1280x1024 */
   "*delay:     5",