[][src]Function colorskill::parse_color

pub fn parse_color(s: &str, reference: (u8, u8, u8)) -> (u8, u8, u8)

Parses a color string Useful for interpreting user input Valid inputs can be: "red", "0,0,0", "0, 0, 0" "darker", "darker2", "darker3" "lighter", "lighter2", "lighter3" or "random" to get a random color The input is lowercased and the whitespaces are removed darker3 turns it 3 times darker than darker Degrees for darker and lighter are hardcoded: DEGREES_1: f64 = 15.0 DEGREES_2: f64 = 30.0 DEGREES_3: f64 = 45.0 Examples:

use colorskill::parse_color;
parse_color("blue", (0, 0, 0));
parse_color("34,65,39", (0, 0, 0));
parse_color("darker", (10, 34, 50));
parse_color("random", (0, 0, 0));