_color_unpack

5 color.module _color_unpack($hex, $normalize = false)
6 color.module _color_unpack($hex, $normalize = false)
7 color.module _color_unpack($hex, $normalize = FALSE)
8 color.module _color_unpack($hex, $normalize = FALSE)

Convert a hex color into an RGB triplet.

3 calls to _color_unpack()

File

modules/color/color.module, line 613

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;
}
Login or register to post comments