function _color_unpack in Drupal 5
Same name and namespace in other branches
- 8 core/modules/color/color.module \_color_unpack()
- 6 modules/color/color.module \_color_unpack()
- 7 modules/color/color.module \_color_unpack()
- 9 core/modules/color/color.module \_color_unpack()
Convert a hex color into an RGB triplet.
3 calls to _color_unpack()
- _color_blend in modules/
color/ color.module - Blend two hex colors and return the GD color.
- _color_gd in modules/
color/ color.module - Convert a hex triplet into a GD color.
- _color_shift in modules/
color/ color.module - Shift a given color, using a reference pair and a target blend color.
File
- modules/
color/ color.module, line 519
Code
function _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;
}