home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_08
/
9n08050a
< prev
next >
Wrap
Text File
|
1991-06-18
|
1KB
|
35 lines
#include <stdlib.h>
#include "pof.h"
char find_color(rgb color, ColorNode *node)
{
int watch;
if (!(color.Red+color.Grn+color.Blu)) return (0); /* 0th Palette case */
watch = (((color.Red < node->key.Red)<<2) +
((color.Grn < node->key.Grn)<<1) +
(color.Blu < node->key.Blu));
if ((watch == 0) && (color.Red == node->key.Red) &&
(color.Grn == node->key.Grn) &&
(color.Blu == node->key.Blu))
return(node->pal_num);
else if (node->Link[watch] != NULL) /* off to next node */
return(find_color(color, node->Link[watch]));
else return(node->pal_num);
}
char ffind_color(float R, float G, float B, ColorNode *node)
{
rgb temp;
temp.Red = (char)(63.0*R);
temp.Grn = (char)(63.0*G);
temp.Blu = (char)(63.0*B);
return(find_color(temp,node));
}