You are here

private function SassColour::hue2rgb in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/script/literals/SassColour.php \SassColour::hue2rgb()

* Converts from hue to RGB colourspace

1 call to SassColour::hue2rgb()
SassColour::hsl2rgb in phamlp/sass/script/literals/SassColour.php
* Converts from HSL to RGB colourspace * Algorithm from the CSS3 spec: {@link http://www.w3.org/TR/css3-color/#hsl-color} * @uses hue2rgb()

File

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

Class

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

Code

private function hue2rgb($m1, $m2, $h) {
  $h += $h < 0 ? 1 : ($h > 1 ? -1 : 0);
  if ($h * 6 < 1) {
    $c = $m2 + ($m1 - $m2) * $h * 6;
  }
  elseif ($h * 2 < 1) {
    $c = $m1;
  }
  elseif ($h * 3 < 2) {
    $c = $m2 + ($m1 - $m2) * (2 / 3 - $h) * 6;
  }
  else {
    $c = $m2;
  }
  return $c * 255;
}