6 #include <grass/display.h>
7 #include <grass/colors.h>
8 #include <grass/raster.h>
9 #include <grass/glocale.h>
11 static struct color_rgb *colors;
32 for (i = 0; i < num_names; i++) {
58 static int translate_or_add_color(
const char *str)
62 int i, preallocated, ret;
63 char lowerstr[MAX_COLOR_LEN];
77 colors = G_malloc(nalloc *
sizeof(
struct color_rgb));
78 for (i = 0; i < ncolors; i++)
91 for (i = 1; i < ncolors; i++)
92 if (colors[i].
r == red && colors[i].
g == grn && colors[i].
b == blu)
95 if (ncolors >= nalloc) {
97 colors = G_realloc(colors, nalloc *
sizeof(
struct color_rgb));
102 colors[index].r = red;
103 colors[index].g = grn;
104 colors[index].b = blu;
127 color = translate_or_add_color(str);
130 if (color == 0 && !none_acceptable)
156 if (color < ncolors) {
157 const struct color_rgb *c = &colors[
color];
185 const struct color_rgb *c;
203 if (color >= ncolors)
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)
void R_standard_color(int index)
select standard color
char * G_chop(char *line)
Chop leading and trailing white spaces:
char * G_tolcase(char *string)
convert string to lower case
char * G_strcpy(char *T, const char *F)
Copies characters from the string F into the string T.
int D_raster_use_color(int color)
draw with a color from D_parse_color
int G_num_standard_color_names(void)
Get number of named colors (color names)
int D_color_number_to_RGB(int color, int *r, int *g, int *b)
get RGB values from color number
struct color_name * G_standard_color_name(int n)
Get color name.
int D_translate_color(const char *str)
color name to number
int G_str_to_color(const char *str, int *red, int *grn, int *blu)
Parse color string and set red,green,blue.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
void R_RGB_color(unsigned char red, unsigned char grn, unsigned char blu)
select color
struct color_rgb G_standard_color_rgb(int n)
Get RGB triplet of given color.
int D_parse_color(const char *str, int none_acceptable)
color option text to usable color number