Common standard for defining a color?
| From: | Stefan Neufeind | Date: | Sun, 01 Feb 2004 23:52:37 +0000 |
| Subject: | Common standard for defining a color? | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-25406@lists.php.net to get a copy of this message | ||
Hi colleagues :-)
Investing a bit further deep into the field of colors (for usage in
new Image_Graph) I stumbled over a question that I'd like to have
discussed on this list. How do we define a color? Let's start with
RGB-color, since this will be the most used one:
Image_Color uses an array with indizes 0,1,2:
array($red, $green, $blue)
Image_Text uses an array with indizes r,g,b to indentify the colors:
array("r" => $red, "g" => $green, "b" => blue)
I see a good point for choosing the Image_Color-way because the array
is easier to construct. However I like the Image_Text-approach a bit
more in reference to "easily readable code" etc. In which direction
should we go? IMHO it would be good to decide on a solution that's
used all across those Image_*-packages etc. because otherwise you
would have to convert between those array-formats - not much usefull
in my eyes.
I'm thinking about a way to handle CMYK etc. also. So going the
Image_Text-way might be preferable? Please comment expressing your
feelings about this!
And one more question that arises: How would I best add an alpha-
value to those arrays? For the Image_Color-approach I would simply
add a fourth value, for the Image_Text-way an "a" => $alpha. Right?
imagecolorallocatealpha() defines a range of 0..127, whereas 0 means
"completely opaque" and 127 "completely transparent". But since the
colors have a range from 0 to 255 and 255 defines full intensity for
a normal color, wouldn't it make more sense to use an alpha of 255 as
"opaque"? Afaik an alpha-value of 0 is "fully transparent" in most
programs, right? Pierre, could you please tell me a bit about this?
Regards
Stefan