src/ATPCore/Lessc.php
protected function toRGB($color) {
if ($color[0] == 'color') return $color;

$H = $color[1] / 360;
$S = $color[2] / 100;
$L = $color[3] / 100;

if ($S == 0) {
$r = $g = $b = $L;
} else {
$temp2 = $L < 0.5 ?
$L*(1.0 + $S) :
$L + $S - $L * $S;

$temp1 = 2.0 * $L - $temp2;

$r = $this->toRGB_helper($H + 1/3, $temp1, $temp2);
$g = $this->toRGB_helper($H, $temp1, $temp2);
$b = $this->toRGB_helper($H - 1/3, $temp1, $temp2);
}

// $out = array('color', round($r*255), round($g*255), round($b*255));
$out = array('color', $r*255, $g*255, $b*255);
if (count($color) > 4) $out[] = $color[4]; // copy alpha
return $out;
}
protected function toRGB($color) {
if ($color[0] == 'color') return $color;

$H = $color[1] / 360;
$S = $color[2] / 100;
$L = $color[3] / 100;

if ($S == 0) {
$r = $g = $b = $L;
} else {
$temp2 = $L < 0.5 ?
$L*(1.0 + $S) :
$L + $S - $L * $S;

$temp1 = 2.0 * $L - $temp2;

$r = $this->toRGB_helper($H + 1/3, $temp1, $temp2);
$g = $this->toRGB_helper($H, $temp1, $temp2);
$b = $this->toRGB_helper($H - 1/3, $temp1, $temp2);
}

// $out = array('color', round($r*255), round($g*255), round($b*255));
$out = array('color', $r*255, $g*255, $b*255);
if (count($color) > 4) $out[] = $color[4]; // copy alpha
return $out;
}
protected function toRGB ( $ color ) { if ( $ color [ 0 ] == 'color' ) return $ color ; $ H = $ color [ 1 ] / 360 ; $ S = $ color [ 2 ] / 100 ; $ L = $ color [ 3 ] / 100 ; if ( $ S == 0 ) { $ r = $ g = $ b = $ L ; } else { $ temp2 = $ L < 0.5 ? $ L * ( 1.0 + $ S ) : $ L + $ S - $ L * $ S ; $ temp1 = 2.0 * $ L - $ temp2 ; $ r = $ this -> toRGB_helper ( $ H + 1 / 3 , $ temp1 , $ temp2 ) ; $ g = $ this -> toRGB_helper ( $ H , $ temp1 , $ temp2 ) ; $ b = $ this -> toRGB_helper ( $ H - 1 / 3 , $ temp1 , $ temp2 ) ; } // $out = array('color', round($r*255), round($g*255), round($b*255));
 $ out = array ( 'color' , $ r * 255 , $ g * 255 , $ b * 255 ) ; if ( count ( $ color ) > 4 ) $ out [ ] = $ color [ 4 ] ; // copy alpha
 return $ out ; }
Converts a hsl array into a color value in rgb.
Expects H to be in range of 0 to 360, S and L in 0 to 100
Converts a hsl array into a color value in rgb . Expects H to be in range of 0 to 360 S and L in 0 to 100