[GRASS5] Hex equivalents of grass colors?

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?

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

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

Thanks. This will be helpful. Should I stick a translation procedure into
gm.tcl, or put it elsewhere?

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@shockfamily.net>
Date: Sat, 15 Apr 2006 18:14:09 -0700
To: <grass5@grass.itc.it>
Cc: Michael Barton <michael.barton@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:
FreeGIS.org

    {"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

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@gclements.plus.com>

Michael,

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?

I wouldn't be abashed putting it in the misc. heading in gui.tcl since color
selection is one of the most obvious things to do with something like
gisprompt. (Playing around color selection code is one of the few things in
my personal little farm right now).

-- Cedric

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@gclements.plus.com>
Date: Sun, 16 Apr 2006 06:14:58 +0100
To: Cedric Shock <cedricgrass@shockfamily.net>
Cc: <grass5@grass.itc.it>, Michael Barton <michael.barton@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:
FreeGIS.org

    {"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@gclements.plus.com>

Hi all,

The grass color sheme is quite old now... Even many years ago, it looked
very poor. Why not use the X-Windows (huge) list of color an introduce
it in grass ? There is quite a lot of tools to see/chose them...

--
Michel Wurtz - Auzeville-Tolosane

--
Michel Wurtz - Auzeville-Tolosane

Michael Barton wrote:

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 } {

[snip]

Just use an array:

array set gcolors {
  white #ffffff
  black #000000
  red #ff0000
  green #00ff00
  blue #0000ff
  yellow #ffff00
  magenta #ff0080
  cyan #00ffff
  aqua #6480ff
  grey #afafaf
  gray #afafaf
  orange #ff8000
  brown #b44d19
  violet #ff00ff
  indigo #0080ff
}

--
Glynn Clements <glynn@gclements.plus.com>

Michel Wurtz wrote:

The grass color sheme is quite old now... Even many years ago, it looked
very poor. Why not use the X-Windows (huge) list of color an introduce
it in grass ? There is quite a lot of tools to see/chose them...

The display drivers pre-allocate all of the standard colours.
Enlarging the list would reduce the number of user-definable colourmap
entries on colour-mapped displays.

Also, the list in X11's rgb.txt (752 entries) wouldn't fit on a
256-colour display.

--
Glynn Clements <glynn@gclements.plus.com>

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@shockfamily.net>
> Date: Sat, 15 Apr 2006 18:14:09 -0700
> To: <grass5@grass.itc.it>
> Cc: Michael Barton <michael.barton@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

This is fine. But what I need is to translate from the GRASS color names to
hex, not RGB, so that they can be used in TclTk canvases and text. Do you
want to put another proc into gui.tcl for this?

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@shockfamily.net>
Date: Sun, 16 Apr 2006 15:48:47 -0700
To: Michael Barton <michael.barton@asu.edu>
Cc: <grass5@grass.itc.it>
Subject: Re: [GRASS5] Hex equivalents of grass colors?

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@shockfamily.net>
Date: Sat, 15 Apr 2006 18:14:09 -0700
To: <grass5@grass.itc.it>
Cc: Michael Barton <michael.barton@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:
FreeGIS.org

    {"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

>> 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

..

> However, this doesn't exactly match the colours used by the display
> drivers. Both the PNG and X drivers use:

..

> 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?

also note ps.map has it's own version, which should probably be brought
into the fold.

https://intevation.de/rt/webrt?serial_num=3049

Hamish

Michael Barton wrote:

This is fine. But what I need is to translate from the GRASS color names to
hex, not RGB, so that they can be used in TclTk canvases and text. Do you
want to put another proc into gui.tcl for this?

  proc color_grass_to_hex {color} {
      eval format #%02X%02X%02X [color_grass_to_rgba255 $color]
  }

--
Glynn Clements <glynn@gclements.plus.com>