pub fn parse_color(color_string: &str) -> Result<Color> {
    let color = color_string.replace(' ', "");
    if color.is_empty() {
        return errors::parse_error("invalid color");
    }

    if color.starts_with("#") {
        return parse_hex(color.as_str());
    }
    if color.starts_with("rgba") {
        return parse_rgba(color.as_str());
    }
    if color.starts_with("rgb") {
        return parse_rgb(color.as_str());
    }
    // TODO: parse hsl & hsla

    return parse_color_name(color.as_str());
}
/// Parsers color value to rgba value
/// 
/// Assumes input string will be trimmed and converted to lowercase
Parsers color value to rgba value
Assumes input string will be trimmed and converted to lowercase
Parsers color value to rgba value Assumes input string will be trimmed and converted to lowercase
pub fn parse_color(color_string: &str) -> Result<Color> {
    let color = color_string.replace(' ', "");
    if color.is_empty() {
        return errors::parse_error("invalid color");
    }
    if color.starts_with("#") {
        return parse_hex(color.as_str());
    }
    if color.starts_with("rgba") {
        return parse_rgba(color.as_str());
    }
    if color.starts_with("rgb") {
        return parse_rgb(color.as_str());
    }
    // TODO: parse hsl & hsla
    return parse_color_name(color.as_str());
}
pub fn parse_color ( color_string : & str ) -> Result < Color > { let color = color_string . replace ( ' ' , " " ) ; if color . is_empty ( ) { return errors :: parse_error ( " " ) ; } if color . starts_with ( " " ) { return parse_hex ( color . as_str ( ) ) ; } if color . starts_with ( " " ) { return parse_rgba ( color . as_str ( ) ) ; } if color . starts_with ( " " ) { return parse_rgb ( color . as_str ( ) ) ; } // TODO: parse hsl & hsla return parse_color_name ( color . as_str ( ) ) ; }
Parsers color value to rgba value
Assumes input string will be trimmed and converted to lowercase
Parsers color value to rgba value Assumes input string will be trimmed and converted to lowercase
color_string
&str
color_string
&str