[][src]Struct pix::hsl::Hsl

pub struct Hsl {}

HSL bi-hexcone color model.

The components are hue, saturation, lightness and optional alpha.

Methods

impl Hsl[src]

pub fn hue<P: Pixel>(p: P) -> P::Chan where
    P: Pixel<Model = Self>, 
[src]

Get the hue component.

Hue is divided into 6 equal intervals arranged into a circle of degrees:

  • 0: Red
  • 60: Yellow
  • 120: Green
  • 180: Cyan
  • 240: Blue
  • 300: Magenta

The degrees are mapped from Channel::MIN (0) to Channel::MAX (360)

Example: Get HSL Hue

use pix::chan::Ch32;
use pix::hsl::{Hsl, Hsl32};

let p = Hsl32::new(0.25, 0.5, 1.0);
assert_eq!(Hsl::hue(p), Ch32::new(0.25));

pub fn hue_mut<P: Pixel>(p: &mut P) -> &mut P::Chan where
    P: Pixel<Model = Self>, 
[src]

Get a mutable reference to the hue component.

Example: Modify HSL Hue

use pix::chan::{Ch32, Channel};
use pix::hsl::{Hsl, Hsl32};

let mut p = Hsl32::new(0.2, 0.75, 0.5);
let mut h = Hsl::hue_mut(&mut p);
*h = h.wrapping_sub(Ch32::new(0.4));
assert_eq!(Hsl::hue(p), Ch32::new(0.8));

pub fn saturation<P: Pixel>(p: P) -> P::Chan where
    P: Pixel<Model = Self>, 
[src]

Get the saturation component.

Lower values are more gray (desaturated), while higher values are more colorful. NOTE: HSL saturation is slightly different from HSV saturation.

Example: HSL Saturation

use pix::chan::Ch16;
use pix::hsl::{Hsl, Hsl16};

let p = Hsl16::new(0x2000, 0x1234, 0x8000);
assert_eq!(Hsl::saturation(p), Ch16::new(0x1234));

pub fn saturation_mut<P: Pixel>(p: &mut P) -> &mut P::Chan where
    P: Pixel<Model = Self>, 
[src]

Get a mutable reference to the saturation component.

Example: Modify HSL Saturation

use pix::chan::Ch16;
use pix::hsl::{Hsl, Hsl16};

let mut p = Hsl16::new(0x2000, 0x1234, 0x8000);
*Hsl::saturation_mut(&mut p) = Ch16::new(0x4321);
assert_eq!(Hsl::saturation(p), Ch16::new(0x4321));

pub fn lightness<P: Pixel>(p: P) -> P::Chan where
    P: Pixel<Model = Self>, 
[src]

Get the lightness component.

Lower values are closer to black, while higher values are closer to white.

Example: HSL Lightness

use pix::chan::Ch8;
use pix::hsl::{Hsl, Hsl8};

let p = Hsl8::new(0x93, 0x80, 0xA0);
assert_eq!(Hsl::lightness(p), Ch8::new(0xA0));

pub fn lightness_mut<P: Pixel>(p: &mut P) -> &mut P::Chan where
    P: Pixel<Model = Self>, 
[src]

Get a mutable reference to the lightness component.

Example: Modify HSL Lightness

use pix::chan::Ch8;
use pix::hsl::{Hsl, Hsl8};

let mut p = Hsl8::new(0x93, 0x80, 0xA0);
*Hsl::lightness_mut(&mut p) = Ch8::new(0xBB);
assert_eq!(Hsl::lightness(p), Ch8::new(0xBB));

Trait Implementations

impl Clone for Hsl[src]

impl ColorModel for Hsl[src]

fn into_rgba<P>(p: P) -> PixRgba<P> where
    P: Pixel<Model = Self>, 
[src]

Convert into red, green, blue and alpha components

fn from_rgba<P>(rgba: PixRgba<P>) -> P where
    P: Pixel<Model = Self>, 
[src]

Convert from red, green, blue and alpha components

impl Copy for Hsl[src]

impl Debug for Hsl[src]

impl Default for Hsl[src]

impl PartialEq<Hsl> for Hsl[src]

impl StructuralPartialEq for Hsl[src]

Auto Trait Implementations

impl RefUnwindSafe for Hsl

impl Send for Hsl

impl Sync for Hsl

impl Unpin for Hsl

impl UnwindSafe for Hsl

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.