pub struct Hwb {}
Implementations§
source§impl Hwb
impl Hwb
sourcepub fn hue<P>(p: P) -> P::Chanwhere
P: Pixel<Model = Self>,
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));
sourcepub fn hue_mut<P>(p: &mut P) -> &mut P::Chanwhere
P: Pixel<Model = Self> + Pixel,
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));
sourcepub fn whiteness<P>(p: P) -> P::Chanwhere
P: Pixel<Model = Self> + Pixel,
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));
sourcepub fn whiteness_mut<P>(p: &mut P) -> &mut P::Chanwhere
P: Pixel<Model = Self> + Pixel,
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));
sourcepub fn blackness<P>(p: P) -> P::Chanwhere
P: Pixel<Model = Self> + Pixel,
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));
sourcepub fn blackness_mut<P>(p: &mut P) -> &mut P::Chanwhere
P: Pixel<Model = Self> + Pixel,
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 ColorModel for Hwb
impl ColorModel for Hwb
impl Copy for Hwb
impl Eq for Hwb
impl StructuralEq for Hwb
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more