Skip to main content

parse_color

Function parse_color 

Source
pub fn parse_color(s: &str) -> Option<Color>
Expand description

Parse a color literal.

Supports hex colors:

  • #rgb (3 digits)
  • #rrggbb (6 digits)
  • #rrggbbaa (8 digits)

§Examples

parse_color("#f00") // Some(Color::from_u8(255, 0, 0, 255))
parse_color("#ff0000") // Some(Color::from_u8(255, 0, 0, 255))