unsigned int cycles;
unsigned int wireframe;
+ unsigned int seamless;
};
struct state {
f->parsedcolors = NULL;
f->cycles = 0;
f->wireframe = 0;
+ f->seamless = 0;
f->fgcolor = 0;
f->bgcolor = 0;
f->visdepth = 0;
switch(depth) {
case 32:
case 24:
-#ifdef HAVE_COCOA
+#ifdef HAVE_JWXYZ
/* This program idiotically does not go through a color map, so
we have to hardcode in knowledge of how jwxyz.a packs pixels!
Fix it to go through st->colors[st->ncolors] instead!
switch(depth) {
case 32:
- ret = 0xff000000;
case 24:
-#ifdef HAVE_COCOA
+#ifdef HAVE_JWXYZ
/* This program idiotically does not go through a color map, so
we have to hardcode in knowledge of how jwxyz.a packs pixels!
Fix it to go through st->colors[st->ncolors] instead!
cx = (int) rx;
cy = (int) ry;
+ if (f->seamless) {
+ cx %= f->width;
+ cy %= f->height;
+ }
if ((cx >= 0) && (cx < f->width) && (cy >= 0) && (cy < f->height)) {
/* safe to check */
for (i = 0; i < grains; i++) {
drawx = (cr->x + (rx - cr->x) * sin(cr->sandp + sin((float) i * w)));
drawy = (cr->y + (ry - cr->y) * sin(cr->sandp + sin((float) i * w)));
+ if (f->seamless) {
+ drawx = fmod(drawx + f->width, f->width);
+ drawy = fmod(drawy + f->height, f->height);
+ }
/* Draw sand bit */
c = trans_point(st, drawx, drawy, cr->sandcolor, (0.1 - i / (grains * 10.0)), f);
/* erase the crack grid */
f->cgrid = (int *) xrealloc(f->cgrid, sizeof(int) * f->height * f->width);
- memset(f->cgrid, 10001, f->height * f->width * sizeof(int));
+ {
+ int j;
+ int *p = f->cgrid;
+ for (j = 0; j < f->height * f->width; j++)
+ *p++ = 10001;
+ }
/* Not necessary now that make_crack ensures we have usable default
* values in start_crack's timeout case
cr->y += ((float) STEP * sin(cr->t * M_PI/180));
}
else {
- float oldx, oldy;
-
- oldx = cr->x;
- oldy = cr->y;
-
cr->x += ((float) cr->ys * cos(cr->t * M_PI/180));
cr->y += ((float) cr->ys * sin(cr->t * M_PI/180));
cr->x += ((float) cr->xs * cos(cr->t * M_PI/180 - M_PI / 2));
- cr->x += ((float) cr->xs * sin(cr->t * M_PI/180 - M_PI / 2));
+ cr->y += ((float) cr->xs * sin(cr->t * M_PI/180 - M_PI / 2));
cr->t += cr->t_inc;
- cr->degrees_drawn += abs(cr->t_inc);
+ cr->degrees_drawn += fabsf(cr->t_inc);
+ }
+ if (f->seamless) {
+ cr->x = fmod(cr->x + f->width, f->width);
+ cr->y = fmod(cr->y + f->height, f->height);
}
/* bounds check */
/* modification of random(-0.33,0.33) */
cx = (int) (cr->x + (frand(0.66) - 0.33));
cy = (int) (cr->y + (frand(0.66) - 0.33));
-
+ if (f->seamless) {
+ cx %= f->width;
+ cy %= f->height;
+ }
if ((cx >= 0) && (cx < f->width) && (cy >= 0) && (cy < f->height)) {
/* draw sand painter if we're not wireframe */
}
/* safe to check */
else if ((f->cgrid[cy * f->width + cx] > 10000) ||
- (abs(f->cgrid[cy * f->width + cx] - cr->t) < 5)) {
+ (fabsf(f->cgrid[cy * f->width + cx] - cr->t) < 5)) {
/* continue cracking */
f->cgrid[cy * f->width + cx] = (int) cr->t;
- } else if (abs(f->cgrid[cy * f->width + cx] - cr->t) > 2) {
+ } else if (fabsf(f->cgrid[cy * f->width + cx] - cr->t) > 2) {
/* crack encountered (not self), stop cracking */
start_crack(f, cr); /* restart ourselves */
make_crack(f); /* generate a new crack */
st->f->wireframe = (get_boolean_resource(st->dpy, "wireFrame", "Boolean"));
st->f->grains = (get_integer_resource(st->dpy, "sandGrains", "Integer"));
st->f->circle_percent = (get_integer_resource(st->dpy, "circlePercent", "Integer"));
+ st->f->seamless = (get_boolean_resource(st->dpy, "seamless", "Boolean"));
if (st->f->initial_cracks <= 2) {
fprintf(stderr, "%s: Initial cracks must be greater than 2\n", progname);
XSetForeground(st->dpy, st->fgc, st->gcv.foreground);
}
+ /* #### mi->recursion_depth = st->f->cycles; */
return st->growth_delay;
}
static Bool
substrate_event (Display *dpy, Window window, void *closure, XEvent *event)
{
+ struct state *st = (struct state *) closure;
+ if (screenhack_event_helper (dpy, window, event))
+ {
+ st->f->cycles = st->max_cycles;
+ return True;
+ }
return False;
}
".foreground: black",
"*fpsSolid: true",
"*wireFrame: false",
+ "*seamless: false",
"*maxCycles: 10000",
"*growthDelay: 18000",
"*initialCracks: 3",
"*maxCracks: 100",
"*sandGrains: 64",
"*circlePercent: 33",
+#ifdef HAVE_MOBILE
+ "*ignoreRotation: True",
+#endif
0
};
{"-background", ".background", XrmoptionSepArg, 0},
{"-foreground", ".foreground", XrmoptionSepArg, 0},
{"-wireframe", ".wireFrame", XrmoptionNoArg, "true"},
+ {"-seamless", ".seamless", XrmoptionNoArg, "true"},
{"-max-cycles", ".maxCycles", XrmoptionSepArg, 0},
{"-growth-delay", ".growthDelay", XrmoptionSepArg, 0},
{"-initial-cracks", ".initialCracks", XrmoptionSepArg, 0},