You are here

function ctools_color_unpack in Chaos Tool Suite (ctools) 6

Convert a hex color into an RGB triplet.

4 calls to ctools_color_unpack()
ctools_color_blend in includes/stylizer.inc
Blend two hex colors and return the GD color.
ctools_color_gd in includes/stylizer.inc
Convert a hex triplet into a GD color.
ctools_stylizer_image_processor::command_colorize in includes/stylizer.inc
Colorize the current workspace with the given location.
ctools_stylizer_image_processor::command_hue in includes/stylizer.inc
Colorize the current workspace with the given location.

File

includes/stylizer.inc, line 1721
Create customized CSS and images from palettes created by user input.

Code

function ctools_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;
}