Struct pix::hwb::Hwb

source ·
pub struct Hwb {}
Expand description

HWB color model.

The components are hue, whiteness, blackness and optional alpha.

Implementations§

source§

impl Hwb

source

pub fn hue<P>(p: P) -> P::Chanwhere P: Pixel<Model = Self>,

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: HWB Hue
use pix::chan::Ch32;
use pix::hwb::{Hwb, Hwb32};

let p = Hwb32::new(0.25, 0.5, 1.0);
assert_eq!(Hwb::hue(p), Ch32::new(0.25));
source

pub fn hue_mut<P>(p: &mut P) -> &mut P::Chanwhere P: Pixel<Model = Self> + Pixel,

Get a mutable reference to the hue component.

Example: Modify HWB Hue
use pix::chan::{Ch32, Channel};
use pix::hwb::{Hwb, Hwb32};

let mut p = Hwb32::new(0.75, 0.5, 0.5);
let mut h = Hwb::hue_mut(&mut p);
*h = h.wrapping_add(0.5.into());
assert_eq!(Hwb::hue(p), Ch32::new(0.25));
source

pub fn whiteness<P>(p: P) -> P::Chanwhere P: Pixel<Model = Self> + Pixel,

Get the whiteness component.

This is the amount of whiteness mixed in with a “pure” hue.

Example: HWB Whiteness
use pix::chan::Ch16;
use pix::hwb::{Hwb, Hwb16};

let p = Hwb16::new(0x2000, 0x2345, 0x5432);
assert_eq!(Hwb::whiteness(p), Ch16::new(0x2345));
source

pub fn whiteness_mut<P>(p: &mut P) -> &mut P::Chanwhere P: Pixel<Model = Self> + Pixel,

Get a mutable reference to the whiteness component.

Example: Modify HWB Whiteness
use pix::chan::Ch16;
use pix::hwb::{Hwb, Hwb16};

let mut p = Hwb16::new(0x2000, 0x1234, 0x8000);
*Hwb::whiteness_mut(&mut p) = Ch16::new(0x4321);
assert_eq!(Hwb::whiteness(p), Ch16::new(0x4321));
source

pub fn blackness<P>(p: P) -> P::Chanwhere P: Pixel<Model = Self> + Pixel,

Get the blackness component.

This is the amount of blackness mixed in with a “pure” hue.

Example: HWB Blackness
use pix::chan::Ch8;
use pix::hwb::{Hwb, Hwb8};

let p = Hwb8::new(0x43, 0x22, 0x19);
assert_eq!(Hwb::blackness(p), Ch8::new(0x19));
source

pub fn blackness_mut<P>(p: &mut P) -> &mut P::Chanwhere P: Pixel<Model = Self> + Pixel,

Get a mutable reference to the blackness component.

Example: Modify HWB Blackness
use pix::chan::Ch8;
use pix::hwb::{Hwb, Hwb8};

let mut p = Hwb8::new(0x93, 0x80, 0xA0);
*Hwb::blackness_mut(&mut p) = Ch8::new(0xBB);
assert_eq!(Hwb::blackness(p), Ch8::new(0xBB));

Trait Implementations§

source§

impl Clone for Hwb

source§

fn clone(&self) -> Hwb

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl ColorModel for Hwb

source§

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

Convert into red, green, blue and alpha components

source§

fn from_rgba<P>(rgba: PixRgba<P>) -> Pwhere P: Pixel<Model = Self>,

Convert from red, green, blue and alpha components

source§

const CIRCULAR: Range<usize> = _

Range of circular channel numbers
source§

const LINEAR: Range<usize> = _

Range of linear channel numbers
source§

const ALPHA: usize = 3usize

Alpha channel number
source§

impl Debug for Hwb

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Hwb

source§

fn default() -> Hwb

Returns the “default value” for a type. Read more
source§

impl PartialEq<Hwb> for Hwb

source§

fn eq(&self, other: &Hwb) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Hwb

source§

impl Eq for Hwb

source§

impl StructuralEq for Hwb

source§

impl StructuralPartialEq for Hwb

Auto Trait Implementations§

§

impl RefUnwindSafe for Hwb

§

impl Send for Hwb

§

impl Sync for Hwb

§

impl Unpin for Hwb

§

impl UnwindSafe for Hwb

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.