In case a package has to deal with colors, it is recommended that
developers store and use an array representation of the color values
in their PEAR packages. All values are in the range of 0..255.
The following snippet defines an array that holds the RGB
definition of the green coloring that is used in the official PEAR
logo.
$color = array(0x33, 0x99, 0x00); |
or
$color = array(51, 153, 0); |
Please note that the internal, numerical representation of both forms
of the example are equal. The values represent the RGB (red, green,
blue) values. It was decided not to use "r", "g" and "b" as indices
for the array, because numerical indices allow easier creation of
color arrays in the sourcecode, make handling less complicated and
are an already commonly used array representation for colors.
The PEAR-package Image_Color
will (hopefully soon) contain all needed functions to convert arbitrary
color formats to the internal RGBA representation and convert different
color representations.
Status: Currently Image_Color already offers functions to convert
color-names (e.g. "green") and hex-representations-strings (e.g.
"#339900") to the PEAR-RGBA-format. We are working to get alpha-
channel support added hopefully soon and will later add funtions for
CYMK-conversion as well.