Same name in other branches
- 8.x-3.x advagg_css_minify/yui/CSSMin.inc \CSSmin::hsl_to_hex()
File
-
advagg_css_minify/
yui/ CSSMin.inc, line 644
Class
Code
private function hsl_to_hex($matches) {
$values = explode(',', str_replace('%', '', $matches[1]));
$h = floatval($values[0]);
$s = floatval($values[1]);
$l = floatval($values[2]);
// Wrap and clamp, then fraction!
$h = ($h % 360 + 360) % 360 / 360;
$s = $this->clamp_number($s, 0, 100) / 100;
$l = $this->clamp_number($l, 0, 100) / 100;
if ($s == 0) {
$r = $g = $b = $this->round_number(255 * $l);
}
else {
$v2 = $l < 0.5 ? $l * (1 + $s) : $l + $s - $s * $l;
$v1 = 2 * $l - $v2;
$r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + 1 / 3));
$g = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h));
$b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - 1 / 3));
}
return $this->rgb_to_hex(array(
'',
$r . ',' . $g . ',' . $b,
$matches[2],
));
}