[−][src]Struct color_name::Color
Implementations
impl Color
[src]
pub fn value(color: color) -> [u8; 3]
[src]
👎 Deprecated since 1.1.0:
Please use val().by_enum() function instead, this function will no longer exist above version 1.1.0 .
Get colour rgb array by enum Colors param.
Example:
use color_name::{ // main function to trait colours Color, // enum colour names use it with Color::value(color:color) // Ex: Color::value(color::red); color }; assert_eq!(Color::value(color::white), [255, 255, 255]);
pub fn by_enum(&self, color: color) -> [u8; 3]
[src]
Get colour rgb array by enum color param.
Example
use color_name::{ Color, color }; assert_eq!(Color::val().by_enum(color::white), [255, 255, 255]);
pub fn by_string(&self, color: String) -> Result<[u8; 3], u16>
[src]
Get colour rgb array by String param.
Example:
use color_name::{ Color }; assert_eq!(Color::val().by_string("InDigo".to_string()).expect("Not found"), [75, 0, 130]); // NOTE: the string can be at any case it will convert it into Title-case assert_eq!(Color::val().by_string("inDigo".to_string()).expect("Not found"), [75, 0, 130]); assert_eq!(Color::val().by_string("IndiGo ".to_string()).expect("Not found"), [75, 0, 130]);
NOTE: Return Result<[u8;3],u16>
as color data [u8;3]
or Not found (404
).
pub fn val() -> Color
[src]
Get value of a color by string OR enum.
pub fn name(rgb: [u8; 3]) -> String
[src]
Get exact colour name if there's no data it return "404".
pub fn similar(rgb: [u8; 3]) -> String
[src]
Get closest colour name match the provided rgb data array.
pub fn close_to(rgb: [u8; 3]) -> String
[src]
Sweet proxy to simlar(rgb)
Auto Trait Implementations
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,