Function csscolorparser::parse[][src]

pub fn parse(s: &str) -> Result<Color, ParseError>

Parse CSS color string

Examples

let c = csscolorparser::parse("#ff0")?;

assert_eq!(c.rgba(), (1., 1., 0., 1.));
assert_eq!(c.rgba_u8(), (255, 255, 0, 255));
assert_eq!(c.to_hex_string(), "#ffff00");
assert_eq!(c.to_rgb_string(), "rgb(255,255,0)");
let c = csscolorparser::parse("hsl(360deg,100%,50%)")?;

assert_eq!(c.rgba(), (1., 0., 0., 1.));
assert_eq!(c.rgba_u8(), (255, 0, 0, 255));
assert_eq!(c.to_hex_string(), "#ff0000");
assert_eq!(c.to_rgb_string(), "rgb(255,0,0)");