Trait ColorSpaceConversion

Source
pub trait ColorSpaceConversion {
    const WHITE_POINT: WhitePoint;

    // Required methods
    fn to_linear_light(from: &ColorComponents) -> ColorComponents;
    fn to_xyz(from: &ColorComponents) -> ColorComponents;
    fn from_xyz(from: &ColorComponents) -> ColorComponents;
    fn to_gamma_encoded(from: &ColorComponents) -> ColorComponents;
}
Expand description

A trait that allows conversion of color spaces to and from XYZ coordinate space with a specified white point.

Allows following the specified method of converting between color spaces:

  • Convert to values to sRGB linear light.
  • Convert to XYZ coordinate space.
  • Adjust white point to target white point.
  • Convert to sRGB linear light in target color space.
  • Convert to sRGB gamma encoded in target color space.

https://drafts.csswg.org/css-color-4/#color-conversion

Required Associated Constants§

Source

const WHITE_POINT: WhitePoint

The white point that the implementer is represented in.

Required Methods§

Source

fn to_linear_light(from: &ColorComponents) -> ColorComponents

Convert the components from sRGB gamma encoded values to sRGB linear light values.

Source

fn to_xyz(from: &ColorComponents) -> ColorComponents

Convert the components from sRGB linear light values to XYZ coordinate space.

Source

fn from_xyz(from: &ColorComponents) -> ColorComponents

Convert the components from XYZ coordinate space to sRGB linear light values.

Source

fn to_gamma_encoded(from: &ColorComponents) -> ColorComponents

Convert the components from sRGB linear light values to sRGB gamma encoded values.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§