Distinct.c File Reference

#include <X11/Xlib.h>
#include <stdlib.h>
#include <X11/Xutil.h>
#include <X11/Xmu/StdCmap.h>

Include dependency graph for Distinct.c:

Go to the source code of this file.

Defines

#define MIN_DISTINGUISH   10000.0

Functions

Bool XmuDistinguishableColors (XColor *colors, int count)
Bool XmuDistinguishablePixels (Display *dpy, Colormap cmap, unsigned long *pixels, int count)


Define Documentation

#define MIN_DISTINGUISH   10000.0

Definition at line 44 of file Distinct.c.

Referenced by XmuDistinguishableColors().


Function Documentation

Bool XmuDistinguishableColors ( XColor *  colors,
int  count 
)

Definition at line 47 of file Distinct.c.

References i, j, and MIN_DISTINGUISH.

Referenced by XmuDistinguishablePixels().

00048 {
00049     double          deltaRed, deltaGreen, deltaBlue;
00050     double          dist;
00051     int             i, j;
00052 
00053     for (i = 0; i < count - 1; i++)
00054         for (j = i + 1; j < count; j++)
00055         {
00056             deltaRed = (double)colors[i].red - (double)colors[j].red;
00057             deltaGreen = (double)colors[i].green - (double)colors[j].green;
00058             deltaBlue = (double)colors[i].blue - (double)colors[j].blue;
00059             dist = deltaRed * deltaRed +
00060                    deltaGreen * deltaGreen +
00061                    deltaBlue * deltaBlue;
00062             if (dist <= MIN_DISTINGUISH * MIN_DISTINGUISH)
00063                 return False;
00064         }
00065     return True;
00066 }

Here is the caller graph for this function:

Bool XmuDistinguishablePixels ( Display *  dpy,
Colormap  cmap,
unsigned long pixels,
int  count 
)

Definition at line 69 of file Distinct.c.

References free(), i, j, malloc(), and XmuDistinguishableColors().

00071 {
00072     XColor  *defs;
00073     int     i, j;
00074     Bool    ret;
00075 
00076     for (i = 0; i < count - 1; i++)
00077         for (j = i + 1; j < count; j++)
00078             if (pixels[i] == pixels[j])
00079                 return False;
00080     defs = (XColor *) malloc (count * sizeof (XColor));
00081     if (!defs)
00082         return False;
00083     for (i = 0; i < count; i++)
00084         defs[i].pixel = pixels[i];
00085     XQueryColors (dpy, cmap, defs, count);
00086     ret = XmuDistinguishableColors (defs, count);
00087     free ((char *) defs);
00088     return ret;
00089 }

Here is the call graph for this function:


Generated on Sun Mar 4 16:03:47 2007 for Scilab [trunk] by  doxygen 1.5.1