[GRASS5] Hex equivalents of grass colors?

Cedric Shock cedricgrass at shockfamily.net
Sun Apr 16 18:48:47 EDT 2006


On Saturday 15 April 2006 21:58, you wrote:
> Thanks. This will be helpful. Should I stick a translation procedure into
> gm.tcl, or put it elsewhere?
>

A procedure related to G_str_to_color (the colors below) is in gui.tcl as

proc color_grass_to_rgba255 {string}

It returns a list of four numbers in [0, 255] for red, green, blue, and alpha.

Examples:

color_grass_to_rgba255 red
{255 0 0 0}
color_grass_to_rgba255 none
{0 0 0 255}
color_grass_to_rgba255 1:200:30
{1 200 30 0}

These colors are only the ones used with these display programs, and possibly 
with some other non-display programs:
d.graph
d.mapgraph
d.path
d.vect
d.vect.chart

I'd hold off on much color stuff of this sort until we get the colors sorted 
out a bit more.

--Cedric

> Michael
> __________________________________________
> Michael Barton, Professor of Anthropology
> School of Human Evolution & Social Change
> Center for Social Dynamics & Complexity
> Arizona State University
>
> phone: 480-965-6213
> fax: 480-965-7671
> www: http://www.public.asu.edu/~cmbarton
>
> > From: Cedric Shock <cedricgrass at shockfamily.net>
> > Date: Sat, 15 Apr 2006 18:14:09 -0700
> > To: <grass5 at grass.itc.it>
> > Cc: Michael Barton <michael.barton at asu.edu>
> > Subject: Re: [GRASS5] Hex equivalents of grass colors?
> >
> > Michael,
> >
> >> Is there some kind of lookup available for the hex equivalent of
> >> standard grass colors (red, violet, etc)? Lacking that, is there an RGB
> >> lookup that I could translate to hex?
> >
> > This is information is on my wish list too. I found it in:
> > http://freegis.org/cgi-bin/viewcvs.cgi/grass6/lib/gis/color_str.c
> >
> >     {"white",   255, 255, 255},
> >     {"black",     0,   0,   0},
> >     {"red",     255,   0,   0},
> >     {"green",     0, 255,   0},
> >     {"blue",      0,   0, 255},
> >     {"yellow",  255, 255,   0},
> >     {"magenta", 255,   0, 255},
> >     {"cyan",      0, 255, 255},
> >     {"aqua",    100, 127, 255},
> >     {"grey",    127, 127, 127},
> >     {"gray",    127, 127, 127},
> >     {"orange",  255, 127,   0},
> >     {"brown",   180,  75,  25},
> >     {"violet",  255,   0, 255},
> >     {"indigo",    0, 127, 255}
> >
> > And of course the red:green:blue format and NONE / none / NonE whatever
> > returns the special no color.
> >
> > I've been playing with colors a bit too. I have a little rgb/his color
> > system color picker that has sliders for red, green, blue, hue,
> > intensity, and saturation. This is possible since, although neither rgb
> > or his is an absolute color space, they are remappings of the same color
> > model.
> >
> > This code snippet takes integer red green and blue values on [0,255] to a
> > hex color for tcl:
> >
> > set rX [format %02X $red]
> > set gX [format %02X $green]
> > set bX [format %02X $blue]
> >
> > set color "#$rX$gX$bX"
> >
> > --Cedric




More information about the grass-dev mailing list