Struct hsl::HSL [] [src]

pub struct HSL {
    pub h: f64,
    pub s: f64,
    pub l: f64,
}

Color represented in HSL

Fields

h: f64

Hue in 0-360 degree

s: f64

Saturation in 0...1 (percent)

l: f64

Luminosity in 0...1 (percent)

Methods

impl HSL
[src]

fn from_rgb(rgb: &[u8]) -> HSL

Convert RGB pixel value to HSL

Expects RGB pixel to be a slice of three u8s representing the red, green and blue values.

use hsl::HSL;
let blue = HSL::from_rgb(&[0, 0, 255]);

Algorithm from go-color by Brandon Thomson bt@brandonthomson.com. (Iternally converts the pixel to RGB before converting it to HSL.)

fn to_rgb(&self) -> (u8, u8, u8)

Convert HSL color to RGB

use hsl::HSL;

let cyan = HSL { h: 180_f64, s: 1_f64, l: 0.5_f64 };
assert_eq!(cyan.to_rgb(), (0, 255, 255));

Trait Implementations

impl Default for HSL
[src]

fn default() -> HSL

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

impl PartialOrd for HSL
[src]

fn partial_cmp(&self, __arg_0: &HSL) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, __arg_0: &HSL) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, __arg_0: &HSL) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, __arg_0: &HSL) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, __arg_0: &HSL) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl PartialEq for HSL
[src]

fn eq(&self, __arg_0: &HSL) -> bool

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

fn ne(&self, __arg_0: &HSL) -> bool

This method tests for !=.

impl Debug for HSL
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.