You are here

function _fivestar_color_unpack in Fivestar 6.2

Same name and namespace in other branches
  1. 5 fivestar_color.inc \_fivestar_color_unpack()
  2. 6 fivestar_color.inc \_fivestar_color_unpack()

Convert a hex color into an RGB triplet.

3 calls to _fivestar_color_unpack()
_fivestar_color_blend in includes/fivestar.color.inc
Blend two hex colors and return the resulting hex color.
_fivestar_color_mask in includes/fivestar.color.inc
Apply a color to a portion of a black and white mask image.
_fivestar_color_render in includes/fivestar.color.inc
Render images that match a given palette.

File

includes/fivestar.color.inc, line 408
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;
}