You are here

function designkit_colorhsl in DesignKit 6

Same name and namespace in other branches
  1. 7 designkit.module \designkit_colorhsl()

Retrieve the HSL of a color, or the specified component.

Parameters

$source: An RGB hex string. The source color from which to retrieve HSL values. @param $key Optional string key (either 'h', 's' or 'l') for the HSL component to retrieve. @return Either an array of HSL values or the single component specified by $key.

File

./designkit.module, line 178

Code

function designkit_colorhsl($source, $key = NULL) {
  if (designkit_valid_color($source)) {
    $source = _color_unpack($source, TRUE);
    $hsl = _color_rgb2hsl($source);
    $keys = array(
      'h' => 0,
      's' => 1,
      'l' => 2,
    );
    if (isset($key, $keys[$key])) {
      return isset($hsl[$keys[$key]]) ? $hsl[$keys[$key]] : NULL;
    }
    return $hsl;
  }
  return NULL;
}