You are here

private function SassColour::hsl2rgb in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/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 phamlp/sass/script/literals/SassColour.php
* Returns the blue component of this colour. *
SassColour::getGreen in phamlp/sass/script/literals/SassColour.php
* Returns the green component of this colour. *
SassColour::getRed in phamlp/sass/script/literals/SassColour.php
* Returns the red component of this colour. *

File

phamlp/sass/script/literals/SassColour.php, line 770

Class

SassColour
SassColour class. A SassScript object representing a CSS colour.

Code

private 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);
}