pixel 0.1.3

Prototype! Pixel manipulation library (blend and convert colors)
Documentation
use super::*;
use super::utils::*;


/// This type describe color by three properties.
/// Hue.
/// Saturation.
/// Lightness.
#[derive(Clone)]
#[derive(Copy)]
pub struct HSL {
    pub hue: f32,
    pub saturation: f32,
    pub lightness: f32
}

impl Color for HSL {
    fn to_rgb(&self) -> RGB {
        let c = (1.0 - (2.0 * self.lightness - 1.0).abs()) * self.saturation;
        let m = self.lightness - c / 2.0;
        rgb_from_hcm(self.hue, c, m)
    }
    fn to_hsv(&self) -> HSV { HSV { hue: self.hue, saturation: get_hsv_saturation(self.to_rgb()), value: get_value(self.to_rgb()) } }
    fn to_hsl(&self) -> HSL { *self }


    fn get_hue(&self) -> f32 where Self: Sized { self.hue }
    fn get_hsl_saturation(&self) -> f32 where Self: Sized { self.saturation }
    fn get_lightness(&self) -> f32 where Self: Sized { self.lightness }
}

impl Pixel for HSL {}

impl FromPixel for HSL {}

impl FromColor for HSL {
    fn from<C: Color>(color: &C) -> HSL { color.to_hsl() }
}