Struct lab::Lab [] [src]

pub struct Lab {
    pub l: f32,
    pub a: f32,
    pub b: f32,
}

Fields

Methods

impl Lab
[src]

Constructs a new Lab from a three-element array of u8s

Examples

let lab = Lab::from_rgb(&[240, 33, 95]);
// Lab { l: 66.6348, a: 52.260696, b: 14.850557 }

Constructs a new Lab from a four-element array of u8s

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 }

Returns the Lab's color in RGB, in a 3-element array.

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]

Formats the value using the given formatter.

impl PartialEq for Lab
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Copy for Lab
[src]

impl Clone for Lab
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Default for Lab
[src]

Returns the "default value" for a type. Read more