#[repr(C)]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)
pub fn scaled_by(&self, by: f32) -> Xyz
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 AddAssign<f32> for Xyz
impl AddAssign<f32> for Xyz
Source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
Performs the
+= operation. Read moreSource§impl AddAssign for Xyz
impl AddAssign for Xyz
Source§fn add_assign(&mut self, rhs: Xyz)
fn add_assign(&mut self, rhs: Xyz)
Performs the
+= operation. Read moreSource§impl DivAssign<f32> for Xyz
impl DivAssign<f32> for Xyz
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
Performs the
/= operation. Read moreSource§impl DivAssign for Xyz
impl DivAssign for Xyz
Source§fn div_assign(&mut self, rhs: Xyz)
fn div_assign(&mut self, rhs: Xyz)
Performs the
/= operation. Read moreSource§impl EuclideanDistance for Xyz
impl EuclideanDistance for Xyz
fn euclidean_distance(&self, other: Xyz) -> f32
Source§impl MulAssign<f32> for Xyz
impl MulAssign<f32> for Xyz
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
Performs the
*= operation. Read moreSource§impl MulAssign for Xyz
impl MulAssign for Xyz
Source§fn mul_assign(&mut self, rhs: Xyz)
fn mul_assign(&mut self, rhs: Xyz)
Performs the
*= operation. Read moreSource§impl SubAssign<f32> for Xyz
impl SubAssign<f32> for Xyz
Source§fn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
Performs the
-= operation. Read moreSource§impl SubAssign for Xyz
impl SubAssign for Xyz
Source§fn sub_assign(&mut self, rhs: Xyz)
fn sub_assign(&mut self, rhs: Xyz)
Performs the
-= operation. Read moreimpl 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§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)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more