public function toRgb() { $mode = $this->mode; $channels = $this->channels; if (!$mode || $mode === 'rgb') { return $this; } if ($mode === 'rgba') { // If we don't need alpha channel, drop it if ($channels['a']->getValue() >= 1) { unset($this->channels['a']); $this->mode = 'rgb'; } return $this; } $rgb = Util\Color::hslToRgb($channels['h']->getValue(), $channels['s']->getValue(), $channels['l']->getValue(), isset($channels['a']) ? $channels['a']->getValue() : 1); $this->channels = array(); foreach ($rgb as $key => $val) { $this->channels[$key] = new Dimension($val); } $this->mode = isset($rgb['a']) ? 'rgba' : 'rgb'; return $this; }