Re: Propsal: Mechanism for converting rgb, hex, and named color strings between one another

Something to keep in mind is that not all rgb() values can in fact be expressed
as in hex format (or, obviously, in name form): CSS2.1 hex format is restricted
to 8 bits per channel, and is restricted to within the gamut of sRGB.
rgb() form has neither of these restrictions.  (Though all colours in CSS2.1
are restricted to the gamut of the target device when this is known.)

(Reference: http://www.w3.org/TR/CSS21/syndata.html#color-units, 
 mainly towards the end of that subsection.)

This is relevant at least to the documentation for such a feature, and may also
affect the choice of representation.  It may even mean that it's worthwhile
providing a separate function to give hex format (either conditionally or
closest approximation).

pjrm.

Received on Sunday, 26 September 2010 12:41:33 UTC