pub struct RgbSpace {
pub white: Chromaticity,
pub to_xyz: Matrix3,
pub from_xyz: Matrix3,
pub transfer: Transfer,
}Expand description
A description of an RGB colour space: its white point, and how to move between its encoded channels and CIE XYZ.
The matrices are relative to the space’s own white point, with Y = 1 for that white.
The constants are the predefined RGB colour spaces of CSS Color 4, with the matrices from its sample code: https://drafts.csswg.org/css-color-4/#color-conversion-code
let white = RgbSpace::SRGB.xyz_from_encoded([1.0, 1.0, 1.0]);
assert!(white.iter().zip(RgbSpace::SRGB.white.xyz()).all(|(a, b)| (a - b).abs() < 1e-12));Fields§
§white: ChromaticityChromaticity of the white point.
to_xyz: Matrix3Linear RGB -> CIE XYZ, at this space’s white point.
from_xyz: Matrix3CIE XYZ -> linear RGB, at this space’s white point.
transfer: TransferThe transfer function between linear light and this space’s encoded channels.
Implementations§
Source§impl RgbSpace
impl RgbSpace
Sourcepub const SRGB_LINEAR: Self
pub const SRGB_LINEAR: Self
sRGB primaries with no transfer function (“srgb-linear”), D65.
https://drafts.csswg.org/css-color-4/#predefined-sRGB-linear
Sourcepub const DISPLAY_P3: Self
pub const DISPLAY_P3: Self
Display P3 (DCI-P3 primaries, sRGB transfer), D65.
Sourcepub const PROPHOTO_RGB: Self
pub const PROPHOTO_RGB: Self
ProPhoto RGB (ROMM RGB), D50.
https://drafts.csswg.org/css-color-4/#predefined-prophoto-rgb
Sourcepub const REC2020: Self
pub const REC2020: Self
ITU-R BT.2020 primaries, D65, with the transfer function described at Transfer::Rec2020.
Sourcepub const fn xyz_from_linear(&self, rgb: [f64; 3]) -> [f64; 3]
pub const fn xyz_from_linear(&self, rgb: [f64; 3]) -> [f64; 3]
Converts linear channels of this space to CIE XYZ at this space’s white point.
Sourcepub const fn linear_from_xyz(&self, xyz: [f64; 3]) -> [f64; 3]
pub const fn linear_from_xyz(&self, xyz: [f64; 3]) -> [f64; 3]
Converts CIE XYZ at this space’s white point to this space’s linear channels.
Trait Implementations§
impl Copy for RgbSpace
impl StructuralPartialEq for RgbSpace
Auto Trait Implementations§
impl Freeze for RgbSpace
impl RefUnwindSafe for RgbSpace
impl Send for RgbSpace
impl Sync for RgbSpace
impl Unpin for RgbSpace
impl UnsafeUnpin for RgbSpace
impl UnwindSafe for RgbSpace
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more