pub enum Color {
}Variants§
A98Rgb(A98Rgb)
DisplayP3(DisplayP3)
Hsv(Hsv)
Hsl(Hsl)
Hex(Hex)
Hwb(Hwb)
Lab(Lab)
Lch(Lch)
LinearRgb(LinearRgb)
Named(Named)
Oklab(Oklab)
Oklch(Oklch)
ProphotoRgb(ProphotoRgb)
Rec2020(Rec2020)
Srgb(Srgb)
XyzD50(XyzD50)
XyzD65(XyzD65)
Implementations§
Source§impl Color
impl Color
Sourcepub fn color_space(&self) -> Option<ColorSpace>
pub fn color_space(&self) -> Option<ColorSpace>
Returns the ColorSpace of this colour, if it maps to a bounded RGB gamut.
Perceptual and CIE spaces (Lab, Lch, Oklab, Oklch, XyzD50, XyzD65) return None — they can represent
colours outside any single RGB gamut.
Sourcepub fn in_gamut_of(&self, space: ColorSpace) -> bool
pub fn in_gamut_of(&self, space: ColorSpace) -> bool
Returns true if this colour can be represented in space without clamping.
If the colour’s own space is a subset of space and the colour is in gamut of its own space, this returns true
without conversion. Otherwise the colour is converted to the target space (via XyzD65) and the RGB channels are
checked against [0,1].
Trait Implementations§
impl Copy for Color
Source§impl From<Color> for ProphotoRgb
impl From<Color> for ProphotoRgb
Source§impl From<ProphotoRgb> for Color
impl From<ProphotoRgb> for Color
Source§fn from(c: ProphotoRgb) -> Self
fn from(c: ProphotoRgb) -> Self
Converts to this type from the input type.
Source§impl Gamut for Color
impl Gamut for Color
Source§fn in_gamut(&self) -> bool
fn in_gamut(&self) -> bool
Returns
true if all colour channels are within the natural bounds of this colour space.
Alpha is not considered — it is always clamped on construction.Source§fn clamp_to_gamut(&self) -> Self
fn clamp_to_gamut(&self) -> Self
Returns a copy with all colour channels naively clamped to the natural bounds. Read more
Source§fn map_to_gamut(self) -> Self
fn map_to_gamut(self) -> Self
Perceptually maps this colour into gamut. Read more
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<C, T> ColorDistance<T> for C
impl<C, T> ColorDistance<T> for C
Source§impl<C, T> WcagColorContrast<T> for C
impl<C, T> WcagColorContrast<T> for C
Source§fn wcag_contrast_ratio(&self, other: T) -> f64
fn wcag_contrast_ratio(&self, other: T) -> f64
Calculate the contrast ratio between
self and other. colors according to WCAG 2.1. Returns a value between
1:1 and 21:1 Read more