public function __construct($colour)
{
if (is_string($colour)) {
$colour = strtolower($colour);
if ($colour === self::TRANSPARENT) {
$this->red = 0;
$this->green = 0;
$this->blue = 0;
$this->alpha = 0;
} else {
if (array_key_exists($colour, self::$svgColours)) {
$colour = self::$svgColours[$colour];
}
if (preg_match(self::EXTRACT_3, $colour, $matches)) {
for ($i = 1; $i < 4; $i++) {
$matches[$i] = str_repeat($matches[$i], 2);
}
} else {
preg_match(self::EXTRACT_6, $colour, $matches);
}
if (empty($matches)) {
throw new SassColourException('Invalid SassColour string', SassScriptParser::$context->node);
}
$this->red = intval($matches[1], 16);
$this->green = intval($matches[2], 16);
$this->blue = intval($matches[3], 16);
$this->alpha = 1;
}
} elseif (is_array($colour)) {
$scheme = $this->assertValid($colour);
if ($scheme == 'rgb') {
$this->red = $colour['red'];
$this->green = $colour['green'];
$this->blue = $colour['blue'];
$this->alpha = isset($colour['alpha']) ? $colour['alpha'] : 1;
} elseif ($scheme == 'hsl') {
$this->hue = $colour['hue'];
$this->saturation = $colour['saturation'];
$this->lightness = $colour['lightness'];
$this->alpha = isset($colour['alpha']) ? $colour['alpha'] : 1;
} else {
$this->red = $colour[0];
$this->green = $colour[1];
$this->blue = $colour[2];
$this->alpha = isset($colour[3]) ? $colour[3] : 1;
}
} else {
throw new SassColourException('Colour must be a array', SassScriptParser::$context->node);
}
}