Converts a HSL color into a RGB color
Paramètres
array $hslValues:
Return value
array
1 call to CSSmin::hslToRgb()
- CSSmin::hslToHex dans advagg_css_compress/
yui/ CSSMin.inc
Fichier
-
advagg_css_compress/
yui/ CSSMin.inc, line 1114
Classe
Code
private function hslToRgb($hslValues) {
$h = floatval($hslValues[0]);
$s = floatval(str_replace('%', '', $hslValues[1]));
$l = floatval(str_replace('%', '', $hslValues[2]));
// Wrap and clamp, then fraction!
$h = ($h % 360 + 360) % 360 / 360;
$s = $this->clampNumber($s, 0, 100) / 100;
$l = $this->clampNumber($l, 0, 100) / 100;
if ($s == 0) {
$r = $g = $b = $this->roundNumber(255 * $l);
}
else {
$v2 = $l < 0.5 ? $l * (1 + $s) : $l + $s - $s * $l;
$v1 = 2 * $l - $v2;
$r = $this->roundNumber(255 * $this->hueToRgb($v1, $v2, $h + 1 / 3));
$g = $this->roundNumber(255 * $this->hueToRgb($v1, $v2, $h));
$b = $this->roundNumber(255 * $this->hueToRgb($v1, $v2, $h - 1 / 3));
}
return array(
$r,
$g,
$b,
);
}