Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Color names to RGB

5 views
Skip to first unread message

AyJay

unread,
Mar 28, 2000, 3:00:00 AM3/28/00
to
Hi,

Is there a list of color names to RGB values. ie. Black -> #000

Reason, there's an app that I am using that is compiled for HP, and
when run errors with the following "unknown color name DarkBlue", I
would like to replace this color with its RGB equivalent.

Where are these color names defined? ie. Why does "DarkBlue" work on
some platforms and not others?

Would using RGB values make the "color" available across platforms?


TIA
---
AyJayR_at_Yahoo.com.au


Sent via Deja.com http://www.deja.com/
Before you buy.

Rolf Schroedter

unread,
Mar 28, 2000, 3:00:00 AM3/28/00
to
Download the Tk sources. You'll find the color definitions in
./xlib/xcolors.c

typedef struct {
char *name;
unsigned char red;
unsigned char green;
unsigned char blue;
} XColorEntry;

static XColorEntry xColors[] = {
"alice blue", 240, 248, 255,
"AliceBlue", 240, 248, 255,
"antique white", 250, 235, 215,
"AntiqueWhite", 250, 235, 215,
"AntiqueWhite1", 255, 239, 219,
...
"yellow4", 139, 139, 0,
"YellowGreen", 154, 205, 50,
NULL, 0, 0, 0
};

AyJay schrieb:


>
> Hi,
>
> Is there a list of color names to RGB values. ie. Black -> #000
>
> Reason, there's an app that I am using that is compiled for HP, and
> when run errors with the following "unknown color name DarkBlue", I
> would like to replace this color with its RGB equivalent.
>
> Where are these color names defined? ie. Why does "DarkBlue" work on
> some platforms and not others?
>
> Would using RGB values make the "color" available across platforms?
>

---------------------------------------------------------------------
German Aerospace Center Rolf Schroedter
Inst. of Planetary Exploration Tel/Fax: +49 (30) 67055-416/384
Rudower Chaussee 5, D-12489 Berlin Internet: Rolf.Sc...@dlr.de

Markus Pietrek

unread,
Mar 28, 2000, 3:00:00 AM3/28/00
to
AyJay wrote:

> Where are these color names defined? ie. Why does "DarkBlue" work on
> some platforms and not others?

/usr/local/lib/X11/rgb.txt


But this file is different on the machines. HP-UX defines less color than
XFree86, so DarkBlue may not work there.

>
> Would using RGB values make the "color" available across platforms?

This is the best way I think when using other than wellknown colors (red, blue
...)
Your application should work on every environment, not only on your development
system. ;-)

--
Markus Pietrek

Tel: +49-761-473099
Fax: +49-761-441063

Web: http://www.concept.de

Concept Engineering GmbH
Burkheimer Strasse 10
D-79111 Freiburg/Germany

Jeffrey Hobbs

unread,
Mar 28, 2000, 3:00:00 AM3/28/00
to AyJay
AyJay wrote:
> Is there a list of color names to RGB values. ie. Black -> #000

# dec2rgb --
#
# Takes a color name or dec triplet and returns a #RRGGBB color.
# If any of the incoming values are greater than 255,
# then 16 bit value are assumed, and #RRRRGGGGBBBB is
# returned, unless $clip is set.
#
# Arguments:
# r red dec value, or list of {r g b} dec value or color name
# g green dec value, or the clip value, if $r is a list
# b blue dec value
# clip Whether to force clipping to 2 char hex
# Results:
# Returns a #RRGGBB or #RRRRGGGGBBBB color
#
proc dec2rgb {r {g 0} {b UNSET} {clip 0}} {
if {![string compare $b "UNSET"]} {
set clip $g
if {[regexp {^-?(0-9)+$} $r]} {
foreach {r g b} $r {break}
} else {
foreach {r g b} [winfo rgb . $r] {break}
}
}
set max 255
set len 2
if {($r > 255) || ($g > 255) || ($b > 255)} {
if {$clip} {
set r [expr {$r>>8}]; set g [expr {$g>>8}]; set b [expr {$b>>8}]
} else {
set max 65535
set len 4
}
}
return [format "#%.${len}X%.${len}X%.${len}X" \
[expr {($r>$max)?$max:(($r<0)?0:$r)}] \
[expr {($g>$max)?$max:(($g<0)?0:$g)}] \
[expr {($b>$max)?$max:(($b<0)?0:$b)}]]
}

--
Jeffrey Hobbs The Tcl Guy
jeffrey.hobbs at scriptics.com Scriptics Corp.

0 new messages