18 #include <grass/gis.h>
19 #include <grass/colors.h>
22 static const struct color_rgb standard_colors_rgb[] = {
41 static const struct color_name standard_color_names[] = {
67 return sizeof(standard_colors_rgb) /
sizeof(standard_colors_rgb[0]);
77 return standard_colors_rgb[
n];
87 return sizeof(standard_color_names) /
sizeof(standard_color_names[0]);
97 return &standard_color_names[
n];
121 G_debug(3,
"G_str_to_color(): str = '%s'", buf);
126 if (sscanf(buf,
"%d%*[,:; ]%d%*[,:; ]%d", red, grn, blu) == 3) {
127 if (*red < 0 || *red > 255 ||
128 *grn < 0 || *grn > 255 || *blu < 0 || *blu > 255)
135 for (i = 0; i < num_names; i++) {
136 const struct color_name *
name = &standard_color_names[i];
139 struct color_rgb rgb = standard_colors_rgb[name->number];
int G_num_standard_colors(void)
Get number of named colors (RGB triplets)
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
char * G_chop(char *line)
Chop leading and trailing white spaces:
char * G_strcpy(char *T, const char *F)
Copies characters from the string F into the string T.
int G_num_standard_color_names(void)
Get number of named colors (color names)
struct color_name * G_standard_color_name(int n)
Get color name.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
int G_debug(int level, const char *msg,...)
Print debugging message.
int G_str_to_color(const char *str, int *red, int *grn, int *blu)
Parse color string and set red,green,blue.
struct color_rgb G_standard_color_rgb(int n)
Get RGB triplet of given color.