-static void
-merge_colors (argc, argv, into_color, mask, increment_p)
- int argc;
- XColor **argv;
- XColor *into_color;
- int mask;
- Bool increment_p;
-{
- int j;
- *into_color = *argv [0];
- into_color->pixel |= mask;
-#define SHORT_INC(x,y) (x = ((((x)+(y)) > 0xFFFF) ? 0xFFFF : ((x)+(y))))
-#define SHORT_DEC(x,y) (x = ((((x)-(y)) < 0) ? 0 : ((x)-(y))))
- for (j = 1; j < argc; j++)
- if (increment_p)
- {
- SHORT_INC (into_color->red, argv[j]->red);
- SHORT_INC (into_color->green, argv[j]->green);
- SHORT_INC (into_color->blue, argv[j]->blue);
- }
- else
- {
- SHORT_DEC (into_color->red, argv[j]->red);
- SHORT_DEC (into_color->green, argv[j]->green);
- SHORT_DEC (into_color->blue, argv[j]->blue);
- }
-#undef SHORT_INC
-#undef SHORT_DEC
-}
-
-/* fill in all the permutations of colors that XAllocColorCells() has
- allocated for us. Thanks Ron, you're an additive kind of guy. */
-static void
-permute_colors (pcolors, colors, count, plane_masks, increment_p)
- XColor *pcolors, *colors;
- int count;
- unsigned long *plane_masks;
- Bool increment_p;
-{
- int out = 0;
- int max = i_exp (2, count);
- if (count > 31) abort ();
- for (out = 1; out < max; out++)
- {
- XColor *argv [32];
- int this_mask = 0;
- int argc = 0;
- int bit;
- for (bit = 0; bit < 32; bit++)
- if (out & (1<<bit))
- {
- argv [argc++] = &pcolors [bit];
- this_mask |= plane_masks [bit];
- }
- merge_colors (argc, argv, &colors [out-1], this_mask, increment_p);
- }
-}
-