int draw_count;
int iterations, delay, rate, box, oily, stir, fluidity;
int draw_count;
int iterations, delay, rate, box, oily, stir, fluidity;
XGetWindowAttributes(st->dpy, st->window, &xgwa);
depth = xgwa.depth;
st->colormap = xgwa.colormap;
XGetWindowAttributes(st->dpy, st->window, &xgwa);
depth = xgwa.depth;
st->colormap = xgwa.colormap;
st->bigwidth = xgwa.width;
st->bigheight = xgwa.height;
st->visual = xgwa.visual;
st->bigwidth = xgwa.width;
st->bigheight = xgwa.height;
st->visual = xgwa.visual;
st->img_loader = load_image_async_simple (0, xgwa.screen, st->window,
st->window, 0, 0);
st->img_loader = load_image_async_simple (0, xgwa.screen, st->window,
st->window, 0, 0);
- make_smooth_colormap(st->dpy, st->visual, st->colormap, colors, &st->ncolors,
+ make_smooth_colormap(st->screen, st->visual, st->colormap,
+ colors, &st->ncolors,
True, /* allocate */
False, /* not writable */
True); /* verbose (complain about failure) */
True, /* allocate */
False, /* not writable */
True); /* verbose (complain about failure) */
static void
add_circle_drop(struct state *st, int x, int y, int radius, int dheight)
{
static void
add_circle_drop(struct state *st, int x, int y, int radius, int dheight)
{
- 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, (radius > 0) ? sqrt(r)/radius : 0));
power = drop_dist[random() % (sizeof(drop_dist)/sizeof(drop_dist[0]))]; /* clumsy */
dheight = (int)(drop * (power + 0.01));
power = drop_dist[random() % (sizeof(drop_dist)/sizeof(drop_dist[0]))]; /* clumsy */
dheight = (int)(drop * (power + 0.01));
- newx = radius + border + (random() % (int)(st->width - 2*border - 2*radius*power));
- newy = radius + border + (random() % (int)(st->height - 2*border - 2*radius*power));
+ tmp_i = (int)(st->width - 2*border - 2*radius*power);
+ tmp_j = (int)(st->height - 2*border - 2*radius*power);
+ newx = radius + border + ((tmp_i > 0) ? random() % tmp_i : 0);
+ newy = radius + border + ((tmp_j > 0) ? random() % tmp_j : 0);
add_circle_drop(st, newx, newy, radius, dheight);
}
break;
add_circle_drop(st, newx, newy, radius, dheight);
}
break;
- newx = radius + border + (random() % (st->width - 2*border - 2*radius));
- newy = radius + border + (random() % (st->height - 2*border - 2*radius));
+ tmp_i = st->width - 2*border - 2*radius;
+ tmp_j = st->height - 2*border - 2*radius;
+ newx = radius + border + ((tmp_i > 0) ? random() % tmp_i : 0);
+ newy = radius + border + ((tmp_j > 0) ? random() % tmp_j : 0);
x = newy * st->width + newx;
for (cy = -radius; cy <= radius; cy++)
for (cx = -radius; cx <= radius; cx++)
x = newy * st->width + newx;
for (cy = -radius; cy <= radius; cy++)
for (cx = -radius; cx <= radius; cx++)
st->rate = get_integer_resource(disp, "rate", "Integer");
st->box = get_integer_resource(disp, "box", "Integer");
st->oily = get_boolean_resource(disp, "oily", "Boolean");
st->rate = get_integer_resource(disp, "rate", "Integer");
st->box = get_integer_resource(disp, "box", "Integer");
st->oily = get_boolean_resource(disp, "oily", "Boolean");
#endif /* HAVE_XSHM_EXTENSION */
st->light = get_integer_resource(disp, "light", "Integer");
#endif /* HAVE_XSHM_EXTENSION */
st->light = get_integer_resource(disp, "light", "Integer");
if (st->fluidity <= 1) st->fluidity = 1;
if (st->fluidity > 16) st->fluidity = 16; /* 16 = sizeof(short) */
if (st->light < 0) st->light = 0;
if (st->fluidity <= 1) st->fluidity = 1;
if (st->fluidity > 16) st->fluidity = 16; /* 16 = sizeof(short) */
if (st->light < 0) st->light = 0;
if (! st->img_loader) { /* just finished */
XWindowAttributes xgwa;
XGetWindowAttributes(st->dpy, st->window, &xgwa);
if (! st->img_loader) { /* just finished */
XWindowAttributes xgwa;
XGetWindowAttributes(st->dpy, st->window, &xgwa);
st->orig_map = XGetImage (st->dpy, st->window, 0, 0,
xgwa.width, xgwa.height,
~0L, ZPixmap);
st->orig_map = XGetImage (st->dpy, st->window, 0, 0,
xgwa.width, xgwa.height,
~0L, ZPixmap);
+ if (!st->img_loader &&
+ st->start_time + st->duration < time ((time_t *) 0)) {
+ XWindowAttributes xgwa;
+ XGetWindowAttributes(st->dpy, st->window, &xgwa);
+ st->img_loader = load_image_async_simple (0, xgwa.screen, st->window,
+ st->window, 0, 0);
+ st->start_time = time ((time_t *) 0);
+ return st->delay;
+ }
+
if (st->rate > 0 && (st->iterations % st->rate) == 0)
add_drop(st, ripple_blob, -SPLASH);
if (st->stir)
if (st->rate > 0 && (st->iterations % st->rate) == 0)
add_drop(st, ripple_blob, -SPLASH);
if (st->stir)
static Bool
ripples_event (Display *dpy, Window window, void *closure, XEvent *event)
{
static Bool
ripples_event (Display *dpy, Window window, void *closure, XEvent *event)
{
{ "-colors", ".colors", XrmoptionSepArg, 0},
{ "-colours", ".colors", XrmoptionSepArg, 0},
{"-delay", ".delay", XrmoptionSepArg, 0},
{ "-colors", ".colors", XrmoptionSepArg, 0},
{ "-colours", ".colors", XrmoptionSepArg, 0},
{"-delay", ".delay", XrmoptionSepArg, 0},
{"-rate", ".rate", XrmoptionSepArg, 0},
{"-box", ".box", XrmoptionSepArg, 0},
{"-water", ".water", XrmoptionNoArg, "True"},
{"-rate", ".rate", XrmoptionSepArg, 0},
{"-box", ".box", XrmoptionSepArg, 0},
{"-water", ".water", XrmoptionNoArg, "True"},