pub fn parse(s: &str) -> Result<Color, ParseColorError>Expand description
Parse CSS color string
ยงExamples
let c = csscolorparser::parse("#ff0")?;
assert_eq!(c.to_array(), [1.0, 1.0, 0.0, 1.0]);
assert_eq!(c.to_rgba8(), [255, 255, 0, 255]);
assert_eq!(c.to_css_hex(), "#ffff00");
assert_eq!(c.to_css_rgb(), "rgb(255 255 0)");let c = csscolorparser::parse("hsl(360deg,100%,50%)")?;
assert_eq!(c.to_array(), [1.0, 0.0, 0.0, 1.0]);
assert_eq!(c.to_rgba8(), [255, 0, 0, 255]);
assert_eq!(c.to_css_hex(), "#ff0000");
assert_eq!(c.to_css_rgb(), "rgb(255 0 0)");