_color_unpack

Versions
5 – 6
_color_unpack($hex, $normalize = false)
7
_color_unpack($hex, $normalize = FALSE)

Convert a hex color into an RGB triplet.

▾ 3 functions call _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.

Code

modules/color/color.module, line 600

<?php
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
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.