#[non_exhaustive]#[repr(u8)]pub enum ColorSpaceTag {
Show 16 variants
Srgb = 0,
LinearSrgb = 1,
Lab = 2,
Lch = 3,
Hsl = 4,
Hwb = 5,
Oklab = 6,
Oklch = 7,
DisplayP3 = 8,
A98Rgb = 9,
ProphotoRgb = 10,
Rec2020 = 11,
Aces2065_1 = 15,
AcesCg = 12,
XyzD50 = 13,
XyzD65 = 14,
}
Expand description
The color space tag for dynamic colors.
This represents a fixed set of known color spaces. The set contains all color spaces in the CSS Color 4 spec and includes some other color spaces useful for computer graphics.
The integer values of these variants can change in breaking releases.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Srgb = 0
The Srgb
color space.
LinearSrgb = 1
The LinearSrgb
color space.
Lab = 2
The Lab
color space.
Lch = 3
The Lch
color space.
Hsl = 4
The Hsl
color space.
Hwb = 5
The Hwb
color space.
Oklab = 6
The Oklab
color space.
Oklch = 7
The Oklch
color space.
DisplayP3 = 8
The DisplayP3
color space.
A98Rgb = 9
The A98Rgb
color space.
ProphotoRgb = 10
The ProphotoRgb
color space.
Rec2020 = 11
The Rec2020
color space.
Aces2065_1 = 15
The Aces2065_1
color space.
AcesCg = 12
The AcesCg
color space.
XyzD50 = 13
The XyzD50
color space.
XyzD65 = 14
The XyzD65
color space.
Implementations§
Source§impl ColorSpaceTag
impl ColorSpaceTag
pub(crate) fn layout(self) -> ColorSpaceLayout
Sourcepub(crate) fn same_analogous(self, other: Self) -> bool
pub(crate) fn same_analogous(self, other: Self) -> bool
Whether all components of the two color spaces are analogous. See also Section 12.2 of CSS Color 4, defining which components are analogous: https://www.w3.org/TR/2024/CRD-css-color-4-20240213/#interpolation-missing.
Note: if color spaces are the same, then they’re also analogous, but in that case we wouldn’t do the conversion, so this function is not guaranteed to return the correct answer in those cases.
pub(crate) fn l_missing(self, missing: Missing) -> bool
pub(crate) fn set_l_missing( self, missing: &mut Missing, components: &mut [f32; 4], )
pub(crate) fn c_missing(self, missing: Missing) -> bool
pub(crate) fn set_c_missing( self, missing: &mut Missing, components: &mut [f32; 4], )
pub(crate) fn h_missing(self, missing: Missing) -> bool
pub(crate) fn set_h_missing( self, missing: &mut Missing, components: &mut [f32; 4], )
Sourcepub fn from_linear_srgb(self, rgb: [f32; 3]) -> [f32; 3]
pub fn from_linear_srgb(self, rgb: [f32; 3]) -> [f32; 3]
Convert an opaque color from linear sRGB.
This is the tagged counterpart of ColorSpace::from_linear_srgb
.
Sourcepub fn to_linear_srgb(self, src: [f32; 3]) -> [f32; 3]
pub fn to_linear_srgb(self, src: [f32; 3]) -> [f32; 3]
Convert an opaque color to linear sRGB.
This is the tagged counterpart of ColorSpace::to_linear_srgb
.
Sourcepub fn convert(self, target: Self, src: [f32; 3]) -> [f32; 3]
pub fn convert(self, target: Self, src: [f32; 3]) -> [f32; 3]
Convert the color components into the target color space.
This is the tagged counterpart of ColorSpace::convert
.
Sourcepub fn from_linear_srgb_absolute(self, rgb: [f32; 3]) -> [f32; 3]
pub fn from_linear_srgb_absolute(self, rgb: [f32; 3]) -> [f32; 3]
Convert an opaque color from linear sRGB, without chromatic adaptation.
For most use-cases you should consider using the chromatically-adapting
ColorSpaceTag::from_linear_srgb
instead.
This is the tagged counterpart of ColorSpace::from_linear_srgb_absolute
.
Sourcepub fn to_linear_srgb_absolute(self, src: [f32; 3]) -> [f32; 3]
pub fn to_linear_srgb_absolute(self, src: [f32; 3]) -> [f32; 3]
Convert an opaque color to linear sRGB, without chromatic adaptation.
For most use-cases you should consider using the chromatically-adapting
ColorSpaceTag::to_linear_srgb
instead.
This is the tagged counterpart of ColorSpace::to_linear_srgb_absolute
.
Sourcepub fn convert_absolute(self, target: Self, src: [f32; 3]) -> [f32; 3]
pub fn convert_absolute(self, target: Self, src: [f32; 3]) -> [f32; 3]
Convert the color components into the target color space, without chromatic adaptation.
For most use-cases you should consider using the chromatically-adapting
ColorSpaceTag::convert
instead.
This is the tagged counterpart of ColorSpace::convert_absolute
. See the documentation
on ColorSpace::convert_absolute
for more information.
Sourcepub fn chromatically_adapt(
self,
src: [f32; 3],
from: Chromaticity,
to: Chromaticity,
) -> [f32; 3]
pub fn chromatically_adapt( self, src: [f32; 3], from: Chromaticity, to: Chromaticity, ) -> [f32; 3]
Chromatically adapt the color between the given white point chromaticities.
This is the tagged counterpart of ColorSpace::chromatically_adapt
.
The color is assumed to be under a reference white point of from
and is chromatically
adapted to the given white point to
. The linear Bradford transform is used to perform the
chromatic adaptation.
Sourcepub fn scale_chroma(self, src: [f32; 3], scale: f32) -> [f32; 3]
pub fn scale_chroma(self, src: [f32; 3], scale: f32) -> [f32; 3]
Scale the chroma by the given amount.
This is the tagged counterpart of ColorSpace::scale_chroma
.
Trait Implementations§
Source§impl CheckedBitPattern for ColorSpaceTag
impl CheckedBitPattern for ColorSpaceTag
Source§type Bits = u8
type Bits = u8
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.Source§fn is_valid_bit_pattern(bits: &u8) -> bool
fn is_valid_bit_pattern(bits: &u8) -> bool
bits
as &Self
.Source§impl Clone for ColorSpaceTag
impl Clone for ColorSpaceTag
Source§fn clone(&self) -> ColorSpaceTag
fn clone(&self) -> ColorSpaceTag
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Contiguous for ColorSpaceTag
impl Contiguous for ColorSpaceTag
Source§type Int = u8
type Int = u8
Source§fn from_integer(value: Self::Int) -> Option<Self>
fn from_integer(value: Self::Int) -> Option<Self>
value
is within the range for valid instances of this type,
returns Some(converted_value)
, otherwise, returns None
. Read moreSource§fn into_integer(self) -> Self::Int
fn into_integer(self) -> Self::Int
C
into the underlying integral type. This
mostly exists otherwise generic code would need unsafe for the value as integer
Read more