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: f32Implementations§
source§impl Xyz
impl Xyz
pub fn new(x: f32, y: f32, z: f32) -> Self
pub fn saturate_x(x: f32) -> f32
pub fn saturate_y(y: f32) -> f32
pub fn saturate_z(z: f32) -> f32
pub fn scale(&self, by: f32) -> Xyz
sourcepub fn to_absolute_luminance(&self, display_nits: f32) -> Xyz
pub fn to_absolute_luminance(&self, display_nits: f32) -> Xyz
Scales XYZ to absolute luminance against display
sourcepub fn to_relative_luminance(&self, display_nits: f32) -> Xyz
pub fn to_relative_luminance(&self, display_nits: f32) -> Xyz
Scales XYZ to absolute luminance against display
source§impl Xyz
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
sourcepub fn from_srgb(rgb: Rgb<u8>) -> Self
pub fn from_srgb(rgb: Rgb<u8>) -> Self
This functions always use sRGB transfer function and Rec.601 primaries with D65 White point
sourcepub fn from_rgb(
rgb: Rgb<u8>,
matrix: &[[f32; 3]; 3],
transfer_function: TransferFunction,
) -> Self
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 exampleSRGB_TO_XYZ_D65transfer_function- Transfer functions for current colorspace
sourcepub fn from_linear_rgb(rgb: &Rgb<f32>, matrix: &[[f32; 3]; 3]) -> Self
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 exampleSRGB_TO_XYZ_D65transfer_function- Transfer functions for current colorspace
pub fn scaled(&self) -> (f32, f32, f32)
source§impl Xyz
impl Xyz
sourcepub fn to_srgb(&self) -> Rgb<u8>
pub fn to_srgb(&self) -> Rgb<u8>
This functions always use sRGB transfer function and Rec.601 primaries with D65 White point
sourcepub fn to_rgb(
&self,
matrix: &[[f32; 3]; 3],
transfer_function: TransferFunction,
) -> Rgb<u8>
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 exampleSRGB_TO_XYZ_D65transfer_function- Transfer functions for current colorspace
Trait Implementations§
source§impl EuclideanDistance for Xyz
impl EuclideanDistance for Xyz
fn euclidean_distance(&self, other: Xyz) -> f32
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> 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)