Struct pix::rgb::Rgb

source · []
pub struct Rgb {}
Expand description

RGB additive color model.

The components are red, green, blue and optional alpha.

Implementations

Get the red component.

Example: RGB Red
use pix::chan::Ch32;
use pix::rgb::{Rgb, Rgb32};

let p = Rgb32::new(0.25, 0.5, 1.0);
assert_eq!(Rgb::red(p), Ch32::new(0.25));

Get a mutable reference to the red component.

Example: Modify RGB Red
use pix::chan::Ch32;
use pix::rgb::{Rgb, Rgb32};

let mut p = Rgb32::new(0.25, 0.5, 1.0);
*Rgb::red_mut(&mut p) = Ch32::new(0.75);
assert_eq!(Rgb::red(p), Ch32::new(0.75));

Get the green component.

Example: RGB Green
use pix::chan::Ch16;
use pix::rgb::{Rgb, Rgb16};

let p = Rgb16::new(0x2000, 0x1234, 0x8000);
assert_eq!(Rgb::green(p), Ch16::new(0x1234));

Get a mutable reference to the green component.

Example: Modify RGB Green
use pix::chan::Ch16;
use pix::rgb::{Rgb, Rgb16};

let mut p = Rgb16::new(0x2000, 0x1234, 0x8000);
*Rgb::green_mut(&mut p) = 0x4321.into();
assert_eq!(Rgb::green(p), Ch16::new(0x4321));

Get the blue component.

Example: RGB Blue
use pix::chan::Ch8;
use pix::rgb::{Rgb, Rgb8};

let p = Rgb8::new(0x93, 0x80, 0xA0);
assert_eq!(Rgb::blue(p), Ch8::new(0xA0));

Get a mutable reference to the blue component.

Example: Modify RGB Blue
use pix::chan::Ch8;
use pix::rgb::{Rgb, Rgb8};

let mut p = Rgb8::new(0x88, 0x77, 0x66);
*Rgb::blue_mut(&mut p) = 0x55.into();
assert_eq!(Rgb::blue(p), Ch8::new(0x55));

Get channel-wise difference

Check if all Channels are within threshold

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Convert into red, green, blue and alpha components

Convert from red, green, blue and alpha components

Range of circular channel numbers

Range of linear channel numbers

Alpha channel number

Formats the value using the given formatter. Read more

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

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

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.