[GRASS5] v.digit color name mismatch

Eric G. Miller egm2 at jps.net
Tue Feb 25 00:06:34 EST 2003


On Sun, Feb 23, 2003 at 09:59:49PM -0800, cheg01 at attbi.com wrote:
> I found the source of the incorrect behavior of the
> v.digit->Customize->Color menu. The color names do not match the colors
> used in the display fo the following reason:
> 
> The colors used in the display are defined in the file
> <grass_dir>/src/include/colors.h:
> 
> #define D_COLOR_LIST:
> "red,orange,yellow,green,blue,indigo,violet,white,black,gray,brown,magenta,
> aqua,grey"
> 
> The color names used in v.digit are defined in the file
> <grass_dir>/src/mapdev/v.digit/color.c:
> 
> static char *color_names[] = {
>      "             ",
>      "     white",
>      "     black",
>      "    yellow",
>      "       blue",
>      "        red",
>      "     green",
>      "   orange",
>      "       grey",
>      " magenta",
>      "      aqua",
>      "    indigo",
>      "     violet",
>      "   brown",
>      "             ",
>      "            "
> };

And, for another source of names in a different ordering,
we can look to: src/libes/gis/named_colr.c

static struct
{
    char *name;
    float r,g,b;
}colors[] =
{
    {"white",	1.00, 1.00, 1.00},
    {"black",	0.00, 0.00, 0.00},
    {"red",	1.00, 0.00, 0.00},
    {"green",	0.00, 1.00, 0.00},
    {"blue",	0.00, 0.00, 1.00},
    {"yellow",	1.00, 1.00, 0.00},
    {"magenta",	1.00, 0.00, 1.00},
    {"cyan",	0.00, 1.00, 1.00},
    {"aqua",    0.00, 0.75, 0.75},
    {"grey",	0.75, 0.75, 0.75},
    {"gray",	0.75, 0.75, 0.75},
    {"orange",	1.00, 0.50, 0.00},
    {"brown",	0.75, 0.50, 0.25},
    {"purple",	0.50, 0.00, 1.00},
    {"violet",	0.50, 0.00, 1.00},
    {"indigo",  0.00, 0.50, 1.00},

    {"",0.0,0.0,0.0}   /* do not delete */
};

In this file is a G_color_name (int) function that returns the name
corresponding to the index, and this order differs from
D_translate_color ("name") which returns the defined macro numbers
from "colors.h".

There is no corresponding D_translate_color, but it would be trivial
to add (making D_translate_color be a wrapper, for say,
G_color_index(const char *name)).

I propose: making D_COLOR_LIST a macro yielding the name of a pointer to
string literal which will be defined in named_colr.c:

Renumber/reorder the color name macros in colors.h to match the colors
struct above.

Add the function G_color_index and make D_translate_color() a 
simple wrapper for it.

I have a sneaking suspicion that will break something where the color
index can't be zero... (display code?)

Finally, the initialize.c file in v.digit can harmonize with the
colors.c file over the names and numbers of colors...


Then again... maybe the bugfix approach is better for 5.0 ...

-- 
echo ">gra.fcw at 2ztr< eryyvZ .T pveR" | rot13 | reverse




More information about the grass-dev mailing list