Struct colorutils_rs::Xyz

source ·
pub struct Xyz {
    pub x: f32,
    pub y: f32,
    pub z: f32,
}
Expand description

A CIE 1931 XYZ color.

Fields§

§x: f32§y: f32§z: f32

Implementations§

source§

impl Xyz

source

pub fn new(x: f32, y: f32, z: f32) -> Self

source

pub fn saturate_x(x: f32) -> f32

source

pub fn saturate_y(y: f32) -> f32

source

pub fn saturate_z(z: f32) -> f32

source

pub fn scale(&self, by: f32) -> Xyz

source

pub fn to_absolute_luminance(&self, display_nits: f32) -> Xyz

Scales XYZ to absolute luminance against display

source

pub fn to_relative_luminance(&self, display_nits: f32) -> Xyz

Scales XYZ to absolute luminance against display

source§

impl Xyz

This class avoid to scale by 100 for a reason: in common there are no need to scale by 100 in digital image processing, Normalized values are speeding up computing. if you need this multiply by yourself or use scaled

source

pub fn to_jzazbz(&self) -> Jzazbz

Converts into Xyz

source

pub fn from_srgb(rgb: Rgb<u8>) -> Self

This functions always use sRGB transfer function and Rec.601 primaries with D65 White point

source

pub fn from_rgb( rgb: Rgb<u8>, matrix: &[[f32; 3]; 3], transfer_function: TransferFunction, ) -> Self

This function converts from non-linear RGB components to XYZ

§Arguments
  • matrix - Transformation matrix from RGB to XYZ, for example SRGB_TO_XYZ_D65
  • transfer_function - Transfer functions for current colorspace
source

pub fn from_linear_rgb(rgb: &Rgb<f32>, matrix: &[[f32; 3]; 3]) -> Self

This function converts from non-linear RGB components to XYZ

§Arguments
  • matrix - Transformation matrix from RGB to XYZ, for example SRGB_TO_XYZ_D65
  • transfer_function - Transfer functions for current colorspace
source

pub fn scaled(&self) -> (f32, f32, f32)

source§

impl Xyz

source

pub fn to_srgb(&self) -> Rgb<u8>

This functions always use sRGB transfer function and Rec.601 primaries with D65 White point

source

pub fn to_rgb( &self, matrix: &[[f32; 3]; 3], transfer_function: TransferFunction, ) -> Rgb<u8>

This functions always use sRGB transfer function and Rec.601 primaries with D65 White point

§Arguments
  • matrix - Transformation matrix from RGB to XYZ, for example SRGB_TO_XYZ_D65
  • transfer_function - Transfer functions for current colorspace
source

pub fn to_linear_rgb(&self, matrix: &[[f32; 3]; 3]) -> Rgb<f32>

This function converts XYZ to linear RGB

§Arguments
  • matrix - Transformation matrix from RGB to XYZ, for example SRGB_TO_XYZ_D65

Trait Implementations§

source§

impl Clone for Xyz

source§

fn clone(&self) -> Xyz

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 Debug for Xyz

source§

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

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

impl Default for Xyz

source§

fn default() -> Xyz

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

impl EuclideanDistance for Xyz

source§

fn euclidean_distance(&self, other: Xyz) -> f32

source§

impl Copy for Xyz

Auto Trait Implementations§

§

impl Freeze for Xyz

§

impl RefUnwindSafe for Xyz

§

impl Send for Xyz

§

impl Sync for Xyz

§

impl Unpin for Xyz

§

impl UnwindSafe for Xyz

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 T
where 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 T
where 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 T
where 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 T
where 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.