Leafo\ScssPhp\Compiler::toRGB PHP Method

toRGB() public method

Convert HSL to RGB
public toRGB ( integer $hue, integer $saturation, integer $lightness ) : array
$hue integer H from 0 to 360
$saturation integer S from 0 to 100
$lightness integer L from 0 to 100
return array
    public function toRGB($hue, $saturation, $lightness)
    {
        if ($hue < 0) {
            $hue += 360;
        }
        $h = $hue / 360;
        $s = min(100, max(0, $saturation)) / 100;
        $l = min(100, max(0, $lightness)) / 100;
        $m2 = $l <= 0.5 ? $l * ($s + 1) : $l + $s - $l * $s;
        $m1 = $l * 2 - $m2;
        $r = $this->hueToRGB($m1, $m2, $h + 1 / 3) * 255;
        $g = $this->hueToRGB($m1, $m2, $h) * 255;
        $b = $this->hueToRGB($m1, $m2, $h - 1 / 3) * 255;
        $out = [Type::T_COLOR, $r, $g, $b];
        return $out;
    }
Compiler