-----Original Message-----
From: Martin Maechler [mailto:maechler@stat.math.ethz.ch]
Sent: Tuesday, March 28, 2000 4:07 PM
To: jens.oehlschlaegel-akiyoshi@mdfactory.de
Cc: R-core@stat.math.ethz.ch
Subject: Re: [Rd] pre summary: mapping of colornames into hsv?
<jens.oehlschlaegel-akiyoshi@mdfactory.de> writes on
Feb.28, 2000 :
Jens> etc/colors.big doesn't do the job currently, as:
Jens> colors.big maps 455 names to rgb in S syntax
Jens> rgb.txt maps 657 names to rgb in C syntax, but
unlike colors() it has
Jens> mixed upper and lower case
Jens> The C source has the information twice
Jens> rgb.c maps 657 names to rgb (mixed upper and lower case)
Jens> graphics.c maps 657 names tp colorstrings (lower case only)
Jens> internal name2col() and R colors() accesses those
in graphics.c
Jens> I tend to create a R representation which copies
the info from
Jens> graphics.c, unless someone plans to export internal
name2col() to
Jens> become an official R function, which of course
would be a less
Jens> redundant solution.
and a day later, Jens provided
.ColorDataBase <- matrix(c(
"white", "#FFFFFF",
"aliceblue", "#F0F8FF",
"antiquewhite", "#FAEBD7",
"antiquewhite1", "#FFEFDB",
"antiquewhite2", "#EEDFCC",
"antiquewhite3", "#CDC0B0",
.............
))
Now, we should stand back for a moment and
think about what functionality we should provide on the R level.
I think we should use the internal accessor functions to ColorDataBase
(in graphics.c) in order ensure consistency not to further
duplicate the
information.
{{Guido: Jens is right that src/gnuwin32/graphapp/rgb.c
kind of replicates the table already available in
src/main/graphics.c
should we separate out this definition from graphics.c
into a global src/main/rgb.c or something else
after which (most of) graphapp/rgb.c wouldn't be needed anymore ?
-- or just declare the tables in Graphics.h and use them in
graphapp as well?
}}
Potential useful functions {from graphics.c} to be made
available on the R
level are
hsv2rgb() (h,s,v) |-> (r,g,b)
rgb2hsv() does *NOT* exist in graphics.c ;
is it possible at all (i.e. is hsv <--> rgb 1:1 ?)}
rgb2col(rgb_ch) |-> uint { := unsigned int }
name2col (ch) |-> uint
number2col(ch) |-> uint
str2col (ch) |-> uint {calling one of the above 3 functions !}
RGB2rgb(r,g,b) |-> #RRGGBB string
col2name(uint) |-> name from colors() or #RRGGBB string
-------
I would tend to provide only
* str2col() returning an R integer() {instead of uint; the
R color model
only needs the low order 24 bits,
see beginning of Graphics.h }
* col2name()
at first, but one might also want
uint <--> (r,g,b) <--> (h,s,v)
o Further ideas ?
o Are 24bit colors okay?
gnuwin32's graphapp seems to use "transparency"
additionally to 3x8 bit RGB {didn't look closely}
Martin