/** * @dataProvider hsl2rgbProvider * @depends testNormalizeFraction **/ public function testHsl2rgb($h, $s, $l, $aExpected) { $aRGB = CSSColorUtils::hsl2rgb($h, $s, $l, $aExpected); // assertEquals because hsl2rgb returns an array of floats, // even if they are rounded $this->assertEquals($aRGB, $aExpected); }
public function toRGB() { $sName = $this->getName(); $aComponents = $this->aComponents; if (!$sName || $sName == 'rgb') { return; } if ($sName == 'rgba') { // If we don't need alpha channel, drop it if ($aComponents['a']->getSize() >= 1) { unset($this->aComponents['a']); $this->setName('rgb'); } return; } $aRGB = CSSColorUtils::hsl2rgb($aComponents['h']->getSize(), $aComponents['s']->getSize(), $aComponents['l']->getSize(), isset($aComponents['a']) ? $aComponents['a']->getSize() : 1); $this->aComponents = array(); foreach ($aRGB as $key => $val) { $this->aComponents[$key] = new CSSSize($val, null, true); } $sName = isset($aRGB['a']) ? 'rgba' : 'rgb'; $this->setName($sName); return $this; }