public static function parse($value) {
        if ($value instanceof Color) {
            return $value;
        }
        
        $value = strtolower("$value");
        
        if (preg_match('/^#?[0-9a-f]{3,8}$/', $value) &&
            self::parseHexColor($value, $result)
        ) {
            return $result;
        }
        
        if (preg_match(
                '/^rgba?\\(([^,]+),([^,]+),([^,]+)(?:,([^,]+))?\\)$/', 
                $value, $matches) &&
            self::parseRgbComponent($matches[1], $r) &&
            self::parseRgbComponent($matches[2], $g) &&
            self::parseRgbComponent($matches[3], $b) &&
            self::parseAlpha(isset($matches[4]) ? $matches[4] : null, $a)
        ) {
            return self::fromRgb($r, $g, $b, (int)(255 * $a));
        }
        
        if (preg_match(
                '/^hsla?\\(([^,]+),([^,]+),([^,]+)(?:,([^,]+))?\\)$/', 
                $value, $matches) &&
            self::parseHue($matches[1], $h) &&
            self::parsePercent($matches[2], $s) &&
            self::parsePercent($matches[3], $l) &&
            self::parseAlpha(isset($matches[4]) ? $matches[4] : null, $a)
        ) {
            return self::fromHsl($h, $s, $l, $a);
        }
        
        $result = self::parseNamedColor($value);
        if ($result !== null) {
            return $result;
        }
        
        throw new \InvalidArgumentException(
            "Cannot parse '$value' as a color.");
    }