Color Art
A rust crate for working with colors and color spaces.
More technical details, please refer to RFC: Construct Color from Color Space.
Usage
Add Dependency
[]
= "0.1"
Color
Construct a color from a string. You can use the from_str method to construct a color from a string. Currently supported color spaces are:
- RGB
- RGBA
- HEX
- HSL
- HSV
For example:
use Color;
use FromStr;
let color = from_str.unwrap;
let color = from_str.unwrap;
let color = from_str.unwrap;
let color = from_str.unwrap;
let color = from_str.unwrap;
Color Space
Stringify a color to a string. You can use the hex, rgb, rgba, hsl, hsv method to stringify a color to a string. For example:
use Color;
use FromStr;
let color = from_str.unwrap;
color.hex; // "#ffff00"
color.rgb; // "rgb(255, 255, 0)"
color.rgba; // "rgba(255, 255, 0, 1)"
color.hsl; // "hsl(60, 100%, 50%)"
color.hsv; // "hsv(60, 100%, 100%)"
random
You can use the random method to construct a random color.
use Color;
let color = random;