[−][src]Struct lab::Lab
Struct representing a color in L*a*b* space
Fields
l: f32
a: f32
b: f32
Implementations
impl Lab
[src]
pub fn from_rgb(rgb: &[u8; 3]) -> Self
[src]
Constructs a new Lab
from a three-element array of u8
s
Examples
let lab = lab::Lab::from_rgb(&[240, 33, 95]); assert_eq!(lab::Lab { l: 52.33686, a: 75.5516, b: 19.998878 }, lab);
pub fn from_rgba(rgba: &[u8; 4]) -> Self
[src]
Constructs a new Lab
from a four-element array of u8
s
The Lab
struct does not store alpha channel information, so the last
u8
representing alpha is discarded. This convenience method exists
in order to easily measure colors already stored in an RGBA array.
Examples
let lab = lab::Lab::from_rgba(&[240, 33, 95, 255]); assert_eq!(lab::Lab { l: 52.33686, a: 75.5516, b: 19.998878 }, lab);
pub fn to_rgb(&self) -> [u8; 3]
[src]
Returns the Lab
's color in RGB, in a 3-element array.
Examples
let lab = lab::Lab { l: 52.330193, a: 75.56704, b: 19.989174 }; let rgb = lab.to_rgb(); assert_eq!([240, 33, 95], rgb);
pub fn squared_distance(&self, other: &Lab) -> f32
[src]
Measures the perceptual distance between the colors of one Lab
and an other
.
Examples
let pink = Lab { l: 66.6348, a: 52.260696, b: 14.850557 }; let websafe_pink = Lab { l: 64.2116, a: 62.519463, b: 2.8871894 }; assert_eq!(254.23636, pink.squared_distance(&websafe_pink));
Trait Implementations
impl Clone for Lab
[src]
impl Copy for Lab
[src]
impl Debug for Lab
[src]
impl Default for Lab
[src]
impl PartialEq<Lab> for Lab
[src]
impl StructuralPartialEq for Lab
[src]
Auto Trait Implementations
impl RefUnwindSafe for Lab
impl Send for Lab
impl Sync for Lab
impl Unpin for Lab
impl UnwindSafe for Lab
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,
pub 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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,