-/* xscreensaver, Copyright (c) 1997 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1997, 2002 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
complain (int wanted_colors, int got_colors,
Bool wanted_writable, Bool got_writable)
{
- if (wanted_writable && !got_writable)
- fprintf(stderr,
- "%s: wanted %d writable colors; got %d read-only colors.\n",
- progname, wanted_colors, got_colors);
-
- else if (wanted_colors > (got_colors + 10))
+ if (got_colors > wanted_colors - 10)
/* don't bother complaining if we're within ten pixels. */
- fprintf(stderr, "%s: wanted %d%s colors; got %d.\n",
- progname, wanted_colors, (got_writable ? " writable" : ""),
- got_colors);
+ return;
+
+ if (wanted_writable && !got_writable)
+ fprintf (stderr,
+ "%s: wanted %d writable colors; got %d read-only colors.\n",
+ progname, wanted_colors, got_colors);
+ else
+ fprintf (stderr, "%s: wanted %d%s colors; got %d.\n",
+ progname, wanted_colors, (got_writable ? " writable" : ""),
+ got_colors);
}
double v[MAXPOINTS];
double total_s = 0;
double total_v = 0;
- Screen *screen = DefaultScreenOfDisplay(dpy); /* #### WRONG! */
+ Screen *screen = (dpy ? DefaultScreenOfDisplay(dpy) : 0); /* #### WRONG! */
+ int loop = 0;
if (*ncolorsP <= 0) return;
for (i = 0; i < npoints; i++)
{
REPICK_THIS_COLOR:
+ if (++loop > 10000) abort();
h[i] = random() % 360;
s[i] = frand(1.0);
v[i] = frand(0.8) + 0.2;
{
int ncolors = *ncolorsP;
Bool wanted_writable = (allocate_p && writable_pP && *writable_pP);
- Screen *screen = DefaultScreenOfDisplay(dpy); /* #### WRONG! */
+ Screen *screen = (dpy ? DefaultScreenOfDisplay(dpy) : 0); /* #### WRONG! */
double S = ((double) (random() % 34) + 66) / 100.0; /* range 66%-100% */
double V = ((double) (random() % 34) + 66) / 100.0; /* range 66%-100% */
0, S, V,
359, S, V,
colors, &ncolors,
- False, True,
+ False, allocate_p,
(writable_pP && *writable_pP));
/* If we tried for writable cells and got none, try for non-writable. */
Bool wanted_writable = (allocate_p && writable_pP && *writable_pP);
int ncolors = *ncolorsP;
int i;
- Screen *screen = DefaultScreenOfDisplay(dpy); /* #### WRONG! */
+ Screen *screen = (dpy ? DefaultScreenOfDisplay(dpy) : 0); /* #### WRONG! */
if (*ncolorsP <= 0) return;