Re: Common standard for defining a color?
| From: | Norbert Mocsnik | Date: | Tue, 03 Feb 2004 17:44:41 +0000 |
| Subject: | Re: Common standard for defining a color? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-25445@lists.php.net to get a copy of this message | ||
Hello,
I don't know if any standard exists on Earth regarding color information storage in arrays.. What about mixing the two ways you wrote about?
array("rgb" => array("r" => $red, "g" => $green, "b" => $blue),
"a" => $alpha);or array("cmyk" => array("c" => $c, "m" => $m, "y" => $y, "k" => $k)); So it can store any combination of color information.. - it's easy to construct this kind of arrays - it's easily readable In my opinion alpha range should be 0-255, and it should be transformed to any range whenever needed. You wrote:
imagecolorallocatealpha() defines a range of 0..127, whereas 0 means "completely opaque" and 127 "completely transparent". I still think the alpha range should be 0-255.
Afaik an alpha-value of 0 is "fully transparent" in most programs, right? In Photoshop it is, and I prefer this way (0 is "fully transparent").Image_* packages really should follow some convention, I think this question was generally a good idea from you. Regards, Norbert Stefan Neufeind wrote:
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