function _fivestar_color_unpack in Fivestar 6
Same name and namespace in other branches
- 5 fivestar_color.inc \_fivestar_color_unpack()
- 6.2 includes/fivestar.color.inc \_fivestar_color_unpack()
Convert a hex color into an RGB triplet.
3 calls to _fivestar_color_unpack()
- _fivestar_color_blend in ./
fivestar_color.inc - Blend two hex colors and return the resulting hex color.
- _fivestar_color_mask in ./
fivestar_color.inc - Apply a color to a portion of a black and white mask image.
- _fivestar_color_render in ./
fivestar_color.inc - Render images that match a given palette.
File
- ./
fivestar_color.inc, line 365 - File containing functions relating to the color widget.
Code
function _fivestar_color_unpack($hex, $normalize = FALSE) {
if (strlen($hex) == 4) {
$hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3];
}
$c = hexdec($hex);
for ($i = 16; $i >= 0; $i -= 8) {
$out[] = ($c >> $i & 0xff) / ($normalize ? 255 : 1);
}
return $out;
}