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     char *name;
00008     float r,g,b;
00009 }colors[] =
00010 {
00011     {"white",   1.00, 1.00, 1.00},
00012     {"black",   0.00, 0.00, 0.00},
00013     {"red",     1.00, 0.00, 0.00},
00014     {"green",   0.00, 1.00, 0.00},
00015     {"blue",    0.00, 0.00, 1.00},
00016     {"yellow",  1.00, 1.00, 0.00},
00017     {"magenta", 1.00, 0.00, 1.00},
00018     {"cyan",    0.00, 1.00, 1.00},
00019     {"aqua",    0.00, 0.75, 0.75},
00020     {"grey",    0.75, 0.75, 0.75},
00021     {"gray",    0.75, 0.75, 0.75},
00022     {"orange",  1.00, 0.50, 0.00},
00023     {"brown",   0.75, 0.50, 0.25},
00024     {"purple",  0.50, 0.00, 1.00},
00025     {"violet",  0.50, 0.00, 1.00},
00026     {"indigo",  0.00, 0.50, 1.00},
00027 
00028     {"",0.00,0.00,0.00} /* do not modify this line */
00029 } ;
00030 
00031 int G_color_values (
00032     char *name,
00033     float *r,float *g,float *b)
00034 {
00035     int i;
00036 
00037     *r = *g = *b = 0.0;
00038     for (i = 0; colors[i].name[0]; i++)
00039         if (strcmp (name, colors[i].name) == 0)
00040         {
00041             *r = colors[i].r;
00042             *g = colors[i].g;
00043             *b = colors[i].b;
00044             return 1;
00045         }
00046     return -1;
00047 }
00048 
00049 char *G_color_name (int n)
00050 {
00051     int i;
00052 
00053     if (n >= 0)
00054         for (i = 0; colors[i].name[0]; i++)
00055             if (i == n)
00056                 return colors[i].name;
00057     return (char *) NULL;
00058 }

Generated on Wed Dec 19 14:59:06 2007 for GRASS by  doxygen 1.5.4