public function SassColour::hsl2rgb in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/sass/script/literals/SassColour.php \SassColour::hsl2rgb()
Converts from HSL to RGB colourspace Algorithm from the CSS3 spec: {@link http://www.w3.org/TR/css3-color/#hsl-color} @uses hue2rgb()
3 calls to SassColour::hsl2rgb()
- SassColour::getBlue in phpsass/
script/ literals/ SassColour.php - Returns the blue component of this colour.
- SassColour::getGreen in phpsass/
script/ literals/ SassColour.php - Returns the green component of this colour.
- SassColour::getRed in phpsass/
script/ literals/ SassColour.php - Returns the red component of this colour.
File
- phpsass/
script/ literals/ SassColour.php, line 777
Class
- SassColour
- SassColour class. A SassScript object representing a CSS colour.
Code
public function hsl2rgb() {
$h = $this->hue / 360;
$s = $this->saturation / 100;
$l = $this->lightness / 100;
$m1 = $l <= 0.5 ? $l * ($s + 1) : $l + $s - $l * $s;
$m2 = $l * 2 - $m1;
$this->red = $this
->hue2rgb($m1, $m2, $h + 1 / 3);
$this->green = $this
->hue2rgb($m1, $m2, $h);
$this->blue = $this
->hue2rgb($m1, $m2, $h - 1 / 3);
}