Non-RGB color representation

From: Date: Thu, 15 Sep 2005 17:42:55 +0000
Subject: Non-RGB color representation
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-39834@lists.php.net to get a copy of this message
I've been doing some more work on Image_Color2 and realized that once I settle on string and array representations of non-RGB colors, for BC reasons, I'll be stuck with them. I'm hoping to get some feedback on what people feel would be the best representation of colors as arrays and strings. My plan is to write up an RFC but I'd like to get any early feedback before that stage. The PEAR manual has recommendations for RGB arrays with and without alpha channels [1]. I would like to amend this to list the hex string format noted as the preferred RGB string format. Every hex string should begin with a leading '#' (so they're easy to recognize in code). Non-RGB Arrays -------------- The standard RGB component uses a range of 0 to 255 but HSV, HSL and CMYK all have components that are typically expressed as floating point values from 0 to 1 or 0% to 100% [2,3,4]. I'm not sure what the best way to represent them using arrays is. Should these components be written as floating point fractions or rounded to percentage integers: HSV/HSL: array(120, 0.5, 0.75) or array(120, 50, 75) CMYK: array(0, 0.5, 1, 0.6) or array(0, 50, 100, 60) Pro for floats: * easier to express fractions i.e array(0, 1/2, 1, 6/10) * most formulas expect floats, not percentages * more precise than integers (though I'm not sure how much of a concern this is) Pro for ints: * uses less memory * makes it easier to compare colors * more (visually?) compatible with the RGB recommendations I also think that the inclusion of a 'type' identifier in the array should be strongly encouraged, not just optional. Non-RGB Strings --------------- Strings are much easier, if there's a percent sign divide by 100 and then treat it as a float. i.e '0%, 50%, 100%, 60%' would be the same as '0, 0.5, 1, 0.6'. Like I said, I want to get some feedback on this and put together an RFC. Maybe I've got the order backwards... should I just dump this into an RFC? Thoughts? Comments? andrew [1] http://pear.php.net/manual/en/developers.faq.colorrepresentation.php [2] http://en.wikipedia.org/wiki/HSV_color_space [3] http://en.wikipedia.org/wiki/HSL_color_space [4] http://en.wikipedia.org/wiki/CMYK_color_space

« previous php.pear.dev (#39834) next »