• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

named_colr.c

Go to the documentation of this file.
00001 #include <grass/gis.h>
00002 #include <string.h>
00003 #include <stdio.h>
00004 
00005 static struct
00006 {
00007     const char *name;
00008     float r, g, b;
00009 } colors[] = {
00010     {"white",  1.00, 1.00, 1.00},
00011     {"black",  0.00, 0.00, 0.00},
00012     {"red",    1.00, 0.00, 0.00},
00013     {"green",  0.00, 1.00, 0.00},
00014     {"blue",   0.00, 0.00, 1.00},
00015     {"yellow", 1.00, 1.00, 0.00},
00016     {"magenta",1.00, 0.00, 1.00},
00017     {"cyan",   0.00, 1.00, 1.00},
00018     {"aqua",   0.00, 0.75, 0.75},
00019     {"grey",   0.75, 0.75, 0.75},
00020     {"gray",   0.75, 0.75, 0.75},
00021     {"orange", 1.00, 0.50, 0.00},
00022     {"brown",  0.75, 0.50, 0.25},
00023     {"purple", 0.50, 0.00, 1.00},
00024     {"violet", 0.50, 0.00, 1.00},
00025     {"indigo", 0.00, 0.50, 1.00},
00026     {"",       0.00, 0.00, 0.00}        /* do not modify this line */
00027 };
00028 
00029 int G_color_values(const char *name, float *r, float *g, float *b)
00030 {
00031     int i;
00032 
00033     *r = *g = *b = 0.0;
00034     for (i = 0; colors[i].name[0]; i++)
00035         if (strcmp(name, colors[i].name) == 0) {
00036             *r = colors[i].r;
00037             *g = colors[i].g;
00038             *b = colors[i].b;
00039             return 1;
00040         }
00041     return -1;
00042 }
00043 
00044 const char *G_color_name(int n)
00045 {
00046     int i;
00047 
00048     if (n >= 0)
00049         for (i = 0; colors[i].name[0]; i++)
00050             if (i == n)
00051                 return colors[i].name;
00052     return NULL;
00053 }

Generated on Wed Oct 13 2010 12:09:29 for GRASS Programmer's Manual by  doxygen 1.7.1