A crate with color names and its values and usefull functions inluded to get similar colour name by RGB data. Based on these named-colors; Inspired heavely by https://github.com/colorjs/color-name.
Usage
Add this to your Cargo.toml:
[]
= "1.0.0"
Add this to your main.rs or any other rust file:
extern crate color_name;
use ;
assert_eq!;
// In case there's no color match that rgb param color it return "404"
assert_eq!;
assert_eq!;
// to get the closest similar colour use similar() or close_to()
//NOTE: close_to() is a proxy to similar()
assert_eq!;
assert_eq!;
assert_eq!;
// Deprecated use val().by_enum()
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// NOTE: the string can be at any case it will convert it into Title-case
assert_eq!;
assert_eq!;
// for lower-case colors
use colors;
assert_eq!;
assert_eq!;
assert_eq!;
// for Snake-case colors
use colors;
assert_eq!;
assert_eq!;
assert_eq!;
...
// Enjoy it !!
Notes:
- Currently (as 2020/09) there is 148 colour name.
- All colours values are
[u8;3]type ([r, g, b]in rang 0..255).
Todo
- Add script to auto generate the following files from csv file:
-
Colors.rs. -
colors.rs. -
colors.rs. -
colors_array.rs.
-
- Improve the whole crate to be able to eliminate these above files.
- Improve the whole crate to be more dynamic and able to extend it with other crates.