Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 983 Bytes

File metadata and controls

51 lines (36 loc) · 983 Bytes

Rust Usage

Rust support is provided by philocalyst/color-names. Add it with:

cargo add colorsnamed

Choosing colors

use colorsnamed;

let black = colorsnamed::Basic::Black;
let teal = colorsnamed::Basic::Teal;
let another = colorsnamed::Xkcd::Tea;

Getting colors

use colorsnamed;

// Get the relevant hex code
let red = colorsnamed::Basic::Red;
let hex = red.hex();

// Figure out if there is a matching color for a hex code!
let ex: colorsnamed::Basic = hex.try_into().unwrap();

Converting colors

use colorsnamed;
use colors;
use rgb::Rgb;

// Convert to the representation of your colorspace of choice.
let correct_color = red.color::<colors::Srgb>();

let red = colorsnamed::Basic::Red;

// Get the RGB representation
let rgb: Rgb = red.rgb();

See the upstream project for more details and updates: philocalyst/color-names