Struct lab::Lab
[−]
[src]
pub struct Lab { pub l: f32, pub a: f32, pub b: f32, }
Fields
l: f32
a: f32
b: f32
Methods
impl Lab
[src]
fn from_rgb(rgb: &[u8; 3]) -> Self
Constructs a new Lab
from a three-element array of u8
s
Examples
let lab = Lab::from_rgb(&[240, 33, 95]); // Lab { l: 66.6348, a: 52.260696, b: 14.850557 }
fn from_rgba(rgba: &[u8; 4]) -> Self
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::from_rgba(&[240, 33, 95, 255]); // Lab { l: 66.6348, a: 52.260696, b: 14.850557 }
fn to_rgb(&self) -> [u8; 3]
Returns the Lab
's color in RGB, in a 3-element array.
fn squared_distance(&self, other: &Lab) -> f32
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 }; let dist = pink.squared_distance(&websafe_pink); // 254.23636
Trait Implementations
impl Debug for Lab
[src]
impl PartialEq for Lab
[src]
fn eq(&self, __arg_0: &Lab) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Lab) -> bool
This method tests for !=
.
impl Copy for Lab
[src]
impl Clone for Lab
[src]
fn clone(&self) -> Lab
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more