parse_hex_to_rgba

Function parse_hex_to_rgba 

Source
pub fn parse_hex_to_rgba(hex: &str) -> Result<Rgba, ColorParserError>
Expand description

Parses a hexadecimal color string into an Rgba struct.

Accepts the following formats:

  • #RRGGBB
  • #RRGGBBAA
  • #RGB
  • #RGBA

§Errors

Returns ColorParserError if the format or characters are invalid.

§Examples

use color_parser::{parse_hex_to_rgba};

let color = parse_hex_to_rgba("#ff8800").unwrap();
assert_eq!(color.red, 255);