Re: Common standard for defining a color?
| From: | Stefan Neufeind | Date: | Tue, 03 Feb 2004 17:49:40 +0000 |
| Subject: | Re: Common standard for defining a color? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-25446@lists.php.net to get a copy of this message | ||
Hi Norbert (and others)!
On 3 Feb 2004 at 18:44, Norbert Mocsnik wrote:
> 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
Well, the additional "array inside an array" makes it unnecessarily
complex in my eyes. You can have a function that checks if "c" and/or
"m" or something is set and assume that it's cmyk - you don't need
another level of complexity. So if you vote that we should move from
the array with indexes 0 to 2 of of Image_Color currently to "r","g"
and "b" (as Toby introducted in Image_Text) I'd prefer that solution.
What about others?
> 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").
Agreed. That's how I would have expected it to be. And I think this way around it's the
"natural way".
> Image_* packages really should follow some convention, I think this
> question was generally a good idea from you.
Thank you! Let's hope others will join this discussion. Please
comment!
Regards,
Stefan
> 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?