Trait style::color::convert::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.

Object Safety§

This trait is not object safe.

Implementors§