ColorSpaceConversion

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§

Source§

impl ColorSpaceConversion for A98Rgb

Source§

const WHITE_POINT: WhitePoint = WhitePoint::D65

Source§

impl ColorSpaceConversion for DisplayP3

Source§

const WHITE_POINT: WhitePoint = WhitePoint::D65

Source§

impl ColorSpaceConversion for DisplayP3Linear

Source§

const WHITE_POINT: WhitePoint = DisplayP3::WHITE_POINT

Source§

impl ColorSpaceConversion for Hsl

Source§

const WHITE_POINT: WhitePoint = Srgb::WHITE_POINT

Source§

impl ColorSpaceConversion for Hwb

Source§

const WHITE_POINT: WhitePoint = Srgb::WHITE_POINT

Source§

impl ColorSpaceConversion for Lab

Source§

const WHITE_POINT: WhitePoint = WhitePoint::D50

Source§

impl ColorSpaceConversion for Lch

Source§

const WHITE_POINT: WhitePoint = Lab::WHITE_POINT

Source§

impl ColorSpaceConversion for Oklab

Source§

const WHITE_POINT: WhitePoint = WhitePoint::D65

Source§

impl ColorSpaceConversion for Oklch

Source§

const WHITE_POINT: WhitePoint = Oklab::WHITE_POINT

Source§

impl ColorSpaceConversion for ProphotoRgb

Source§

const WHITE_POINT: WhitePoint = WhitePoint::D50

Source§

impl ColorSpaceConversion for Rec2020

Source§

const WHITE_POINT: WhitePoint = WhitePoint::D65

Source§

impl ColorSpaceConversion for Srgb

Source§

const WHITE_POINT: WhitePoint = WhitePoint::D65

Source§

impl ColorSpaceConversion for SrgbLinear

Source§

const WHITE_POINT: WhitePoint = Srgb::WHITE_POINT

Source§

impl ColorSpaceConversion for XyzD50

Source§

const WHITE_POINT: WhitePoint = WhitePoint::D50

Source§

impl ColorSpaceConversion for XyzD65

Source§

const WHITE_POINT: WhitePoint = WhitePoint::D65