pub struct Oklch {
pub lightness: f32,
pub chroma: f32,
pub hue: f32,
pub alpha: f32,
}Expand description
A color in the perceptual OKLCH space: lightness from 0 to 1, chroma
from 0 upward (roughly 0.4 at the edge of wide gamuts), and hue in
degrees. Equal lightness steps read as equal visual steps, which makes it
the natural space for deriving hover, pressed, and contrast variants.
Fields§
§lightness: f32§chroma: f32§hue: f32§alpha: f32Implementations§
Source§impl Oklch
impl Oklch
pub const fn new(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Oklch
pub const fn with_lightness(self, lightness: f32) -> Oklch
pub const fn with_chroma(self, chroma: f32) -> Oklch
Sourcepub fn to_srgb(self) -> Color
pub fn to_srgb(self) -> Color
Encoded sRGB, gamut-mapped by reducing chroma at constant lightness and hue so the result stays recognizably the same color.
Sourcepub fn to_display_p3(self) -> Color
pub fn to_display_p3(self) -> Color
Encoded Display P3, gamut-mapped by reducing chroma.
Sourcepub fn to_linear_display_p3(self) -> Color
pub fn to_linear_display_p3(self) -> Color
Linear Display P3, gamut-mapped by reducing chroma. Useful as the base for extended-range HDR variants that scale linear light.
Sourcepub fn max_srgb_chroma(self) -> f32
pub fn max_srgb_chroma(self) -> f32
The most saturated chroma sRGB can display at this lightness and hue.
Sourcepub fn max_display_p3_chroma(self) -> f32
pub fn max_display_p3_chroma(self) -> f32
The most saturated chroma Display P3 can display at this lightness and hue.
Trait Implementations§
impl Copy for Oklch
impl StructuralPartialEq for Oklch
Auto Trait Implementations§
impl Forget for Oklch
impl Freeze for Oklch
impl Move for Oklch
impl RefUnwindSafe for Oklch
impl Send for Oklch
impl Sync for Oklch
impl Unpin for Oklch
impl UnsafeUnpin for Oklch
impl UnwindSafe for Oklch
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.