X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fcoral.c;h=9603455e42cef7866fb7f853beba7e5babf663eb;hp=b69f4361c2b34afd5c6f4079082d796e61fa5b00;hb=07faf451b99879183ed7e909e43a0e065be1ee7f;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439 diff --git a/hacks/coral.c b/hacks/coral.c index b69f4361..9603455e 100644 --- a/hacks/coral.c +++ b/hacks/coral.c @@ -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; }