14 r(1.0),
g(0.0),
b(0.0),
a(1.0)
19 double epsilon = 1e-4;
20 return( fabs(
r-other.
r) > epsilon ||
21 fabs(
g-other.
g) > epsilon ||
22 fabs(
b-other.
b) > epsilon ||
23 fabs(
a-other.
a) > epsilon );
27 r(1),
g(0),
b(0),
a(1)
32 static FILE *file = NULL;
33 static std::map<std::string,Color> table;
38 file = fopen( rgbFile.c_str(),
"r" );
42 PRINT_ERR1(
"unable to open color database: %s " 43 "(try adding rgb.txt's location to your STAGEPATH)",
55 if (!fgets(line,
sizeof(line), file))
60 if (line[0] ==
'!' || line[0] ==
'#' || line[0] ==
'%' || line[0] ==
'\0')
64 while (strchr(
" \t\n", line[strlen(line)-1]))
65 line[strlen(line)-1] = 0;
69 int chars_matched = 0;
70 sscanf( line,
"%d %d %d %n", &r, &g, &b, &chars_matched );
73 const char* colorname = line + chars_matched;
76 table[colorname] =
Color( r/255.0, g/255.0, b/255.0 );
82 Color& found = table[name];
92 return( ! ((*
this) != other) );
97 return Color( drand48(), drand48(), drand48() );
102 printf(
"%s [%.2f %.2f %.2f %.2f]\n", prefix,
r,
g,
b,
a );
109 const std::string& colorstr = wf->
ReadString( section,
"color",
"" );
112 if( colorstr ==
"random" )
130 wf->
ReadTuple( section,
"color_rgba", 0, 4,
"ffff", &
r, &
g, &
b, &
a );
The Stage library uses its own namespace.
const std::string ReadString(int entity, const char *name, const std::string &value)
static Color RandomColor()
int ReadTuple(const int entity, const char *name, const unsigned int first, const unsigned int num, const char *format,...)
const Color & Load(Worldfile *wf, int entity)
bool PropertyExists(int section, const char *token)
static std::string findFile(const std::string &filename)
bool operator!=(const Color &other) const
bool operator==(const Color &other) const
void Print(const char *prefix) const