[−][src]Crate csscolorparser
Overview
Rust library for parsing CSS color string.
Examples
let c = csscolorparser::parse("rgb(100%,0%,0%)").unwrap(); assert_eq!(c.rgba(), (1.0, 0.0, 0.0, 1.0)); 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)");
Hexadecimal color format with transparency
use csscolorparser::Color; let c = "#ff00007f".parse::<Color>().unwrap(); assert_eq!(c.rgba_u8(), (255, 0, 0, 127)); assert_eq!(c.to_hex_string(), "#ff00007f");
Structs
Color | The color |
Enums
ParseError |
Functions
parse | Parse CSS color string |