[GRASS5] Hex equivalents of grass colors?
Michael Barton
michael.barton at asu.edu
Sun Apr 16 03:58:33 EDT 2006
OK. Using Glynn's version of RGB equivalents for GRASS colors, below is a
TclTk procedure to convert to hex.
Cedrick,
Do you want to put it into gui.tcl? How to reference it from other routines?
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
##### grass colors to hex in TclTk
proc { gcolor } {
switch $gcolor {
"white" {
set xcolor "#ffffff"
}
"black" {
set xcolor "#000000"
}
"red" {
set xcolor "#ff0000"
}
"green"{
set xcolor "#00ff00"
}
"blue" {
set xcolor "#0000ff"
}
"yellow" {
set xcolor "#ffff00"
}
"magenta" {
set xcolor "#ff0080"
}
"cyan" {
set xcolor "#00ffff"
}
"aqua" {
set xcolor "#6480ff"
}
"grey" {
set xcolor "#afafaf"
}
"gray" {
set xcolor "#afafaf"
}
"orange" {
set xcolor "#ff8000"
}
"brown" {
set xcolor "#b44d19"
}
"violet" {
set xcolor "#ff00ff"
}
"indigo" {
set xcolor "#0080ff"
}
}
return $xcolor
}
##############
> From: Glynn Clements <glynn at gclements.plus.com>
> Date: Sun, 16 Apr 2006 06:14:58 +0100
> To: Cedric Shock <cedricgrass at shockfamily.net>
> Cc: <grass5 at grass.itc.it>, Michael Barton <michael.barton at asu.edu>
> Subject: Re: [GRASS5] Hex equivalents of grass colors?
>
>
> Cedric Shock wrote:
>
>> 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}
>
> However, this doesn't exactly match the colours used by the display
> drivers. Both the PNG and X drivers use:
>
> LIB_assign_standard_color(RED, DRV_lookup_color(255, 0, 0));
> LIB_assign_standard_color(ORANGE, DRV_lookup_color(255, 128, 0));
> LIB_assign_standard_color(YELLOW, DRV_lookup_color(255, 255, 0));
> LIB_assign_standard_color(GREEN, DRV_lookup_color( 0, 255, 0));
> LIB_assign_standard_color(BLUE, DRV_lookup_color( 0, 0, 255));
> LIB_assign_standard_color(INDIGO, DRV_lookup_color( 0, 128, 255));
> LIB_assign_standard_color(VIOLET, DRV_lookup_color(255, 0, 255));
> LIB_assign_standard_color(BLACK, DRV_lookup_color( 0, 0, 0));
> LIB_assign_standard_color(WHITE, DRV_lookup_color(255, 255, 255));
> LIB_assign_standard_color(GRAY, DRV_lookup_color(175, 175, 175));
> LIB_assign_standard_color(BROWN, DRV_lookup_color(180, 77, 25));
> LIB_assign_standard_color(MAGENTA, DRV_lookup_color(255, 0, 128));
> LIB_assign_standard_color(AQUA, DRV_lookup_color(100, 128, 255));
>
> The main differences are for magenta and grey. The driver's magenta is
> definitely wrong, as magenta is supposed to be one of the corners of
> the RGB cube; maybe those values should be used for violet?
>
> --
> Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list