Struct kolor_64::ColorSpace

source ·
pub struct ColorSpace { /* private fields */ }
Expand description

A color space defined in data by its Primaries, white point, and an optional invertible transform function.

See spaces for defined color spaces.

ColorSpace assumes that a color space is one of

  • the CIE XYZ color space
  • an RGB color space
  • a color space which may be defined as an invertible mapping from one the above (TransformFn)

An example of a TransformFn is the sRGB “opto-eletronic transfer function”, or “gamma compensation”.

kolor makes the distinction between “linear” and “non-linear” color spaces, where a linear color space can be defined as a linear transformation from the CIE XYZ color space.

ColorSpace contains a reference WhitePoint to represent a color space’s reference illuminant.

A linear RGB ColorSpace can be thought of as defining a relative coordinate system in the CIE XYZ color coordinate space, where three RGB primaries each define an axis pointing from the black point (0,0,0) in CIE XYZ.

Non-linear ColorSpaces - such as sRGB with gamma compensation applied - are defined as a non-linear mapping from a linear ColorSpace’s coordinate system.

Implementations§

source§

impl ColorSpace

source

pub const fn new( primaries: RGBPrimaries, white_point: WhitePoint, transform_fn: TransformFn ) -> Self

source

pub fn is_linear(&self) -> bool

Whether the color space has a non-linear transform applied

source

pub fn as_linear(&self) -> Self

source

pub fn primaries(&self) -> RGBPrimaries

source

pub fn white_point(&self) -> WhitePoint

source

pub fn transform_function(&self) -> TransformFn

source

pub fn with_transform(&self, new_transform: TransformFn) -> Self

Creates a new color space with the primaries and white point from this, but with the provided TransformFn.

source

pub fn with_whitepoint(&self, new_wp: WhitePoint) -> Self

Creates a new color space with the transform function and white point from this, but with the provided WhitePoint.

source

pub fn with_primaries(&self, primaries: RGBPrimaries) -> Self

Creates a new color space with the primaries and transform function from this, but with the provided RGBPrimaries.

source

pub fn to_cielab(&self) -> Self

Creates a CIE LAB color space using this space’s white point.

source

pub fn to_cie_xyY(&self) -> Self

Creates a CIE uvV color space using this space’s white point.

source

pub fn to_cielch(&self) -> Self

Creates a CIE LCh color space using this space’s white point.

Trait Implementations§

source§

impl Clone for ColorSpace

source§

fn clone(&self) -> ColorSpace

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ColorSpace

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for ColorSpace

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<ColorSpace> for ColorSpace

source§

fn eq(&self, other: &ColorSpace) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for ColorSpace

source§

impl Eq for ColorSpace

source§

impl StructuralEq for ColorSpace

source§

impl StructuralPartialEq for ColorSpace

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.