X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fripples.c;h=fac61995060e103740a8c5212a1ce64237189925;hp=aa286426a960537ce62e6360e1d049bde3d50001;hb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;hpb=de460e831dc8578acfa8b72251ab9346c99c1f96 diff --git a/hacks/ripples.c b/hacks/ripples.c index aa286426..fac61995 100644 --- a/hacks/ripples.c +++ b/hacks/ripples.c @@ -718,19 +718,21 @@ sinc(struct state *st, double x) static void add_circle_drop(struct state *st, int x, int y, int radius, int dheight) { - int i, r2, cx, cy; + int r, r2, cx, cy; short *buf = (random()&1) ? st->bufferA : st->bufferB; - i = y * st->width + x; r2 = radius * radius; + for (cy = -radius; cy <= radius; cy++) for (cx = -radius; cx <= radius; cx++) { - int r = cx*cx + cy*cy; - if (r <= r2) { - buf[i + cx + cy*st->width] = - (short)(dheight * sinc(st, sqrt(r)/radius)); - } + int xx = x+cx; + int yy = y+cy; + if (xx < 0 || yy < 0 || xx >= st->width || yy >= st->height) {break;} + r = cx*cx + cy*cy; + if (r > r2) break; + buf[xx + yy*st->width] = + (short)(dheight * sinc(st, sqrt(r)/radius)); } } @@ -1091,11 +1093,11 @@ static const char *ripples_defaults[] = "*duration: 120", "*rate: 5", "*box: 0", - "*water: False", + "*water: True", "*oily: False", "*stir: False", "*fluidity: 6", - "*light: 0", + "*light: 4", "*grayscale: False", #ifdef HAVE_XSHM_EXTENSION "*useSHM: True",