[−][src]Enum nannou::color::Color
A generic color type.
The Color
may belong to any color space and it may change
depending on which operation is performed. That makes it immune to
the "without conversion" rule of the operations it supports. The
color spaces are selected as follows:
Mix
: RGB for no particular reason, except that it's intuitive.Shade
: CIE Lab* for its luminance component.Hue
andGetHue
: CIE LCh° for its hue component and how it preserves the apparent lightness.Saturate
: CIE LCh° for its chromaticity component and how it preserves the apparent lightness.
It's not recommended to use Color
when full control is necessary,
but it can easily be converted to a fixed color space in those
cases.
Variants
Luma(Luma<T>)
Linear luminance.
Rgb(Rgb<T>)
Linear RGB.
Xyz(Xyz<T>)
CIE 1931 XYZ.
Yxy(Yxy<T>)
CIE 1931 Yxy.
Lab(Lab<T>)
CIE Lab* (CIELAB).
Lch(Lch<T>)
CIE LCh°, a polar version of CIE Lab*.
Hsv(Hsv<T>)
Linear HSV, a cylindrical version of RGB.
Hsl(Hsl<T>)
Linear HSL, a cylindrical version of RGB.
Hwb(Hwb<T>)
Linear HWB, an intuitive cylindrical version of RGB.
Methods
impl<T> Color<T> where
T: Float,
[src]
T: Float,
pub fn y(luma: T) -> Color<T>
[src]
Linear luminance.
pub fn y_u8(luma: u8) -> Color<T>
[src]
Linear luminance from an 8 bit value.
pub fn rgb(red: T, green: T, blue: T) -> Color<T>
[src]
Linear RGB.
pub fn rgb_u8(red: u8, green: u8, blue: u8) -> Color<T>
[src]
Linear RGB from 8 bit values.
pub fn xyz(x: T, y: T, z: T) -> Color<T>
[src]
CIE XYZ.
pub fn yxy(x: T, y: T, luma: T) -> Color<T>
[src]
CIE Yxy.
pub fn lab(l: T, a: T, b: T) -> Color<T>
[src]
CIE Lab*.
pub fn lch(l: T, chroma: T, hue: LabHue<T>) -> Color<T>
[src]
CIE LCh°.
pub fn hsv(hue: RgbHue<T>, saturation: T, value: T) -> Color<T>
[src]
Linear HSV.
pub fn hsl(hue: RgbHue<T>, saturation: T, lightness: T) -> Color<T>
[src]
Linear HSL.
pub fn hwb(hue: RgbHue<T>, whiteness: T, balckness: T) -> Color<T>
[src]
Linear HWB.
Trait Implementations
impl<T> ApproxEq for Color<T> where
T: Float + ApproxEq,
<T as ApproxEq>::Epsilon: Copy,
<T as ApproxEq>::Epsilon: Float,
[src]
T: Float + ApproxEq,
<T as ApproxEq>::Epsilon: Copy,
<T as ApproxEq>::Epsilon: Float,
type Epsilon = <T as ApproxEq>::Epsilon
Used for specifying relative comparisons.
fn default_epsilon() -> <Color<T> as ApproxEq>::Epsilon
[src]
fn default_max_relative() -> <Color<T> as ApproxEq>::Epsilon
[src]
fn default_max_ulps() -> u32
[src]
fn relative_eq(
&self,
other: &Color<T>,
epsilon: <Color<T> as ApproxEq>::Epsilon,
max_relative: <Color<T> as ApproxEq>::Epsilon
) -> bool
[src]
&self,
other: &Color<T>,
epsilon: <Color<T> as ApproxEq>::Epsilon,
max_relative: <Color<T> as ApproxEq>::Epsilon
) -> bool
fn ulps_eq(
&self,
other: &Color<T>,
epsilon: <Color<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
[src]
&self,
other: &Color<T>,
epsilon: <Color<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of ApproxEq::relative_eq
.
fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
[src]
The inverse of ApproxEq::ulps_eq
.
impl<T> From<Yxy<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Srgb<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Lab<T>, T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Alpha<Lch<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Lch<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Yxy<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Hwb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Hsv<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Hsl<T> where
T: Float,
[src]
T: Float,
impl<T> From<Luma<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Alpha<Luma<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Lch<T>, T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Alpha<Hsl<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Xyz<T>, T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Srgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Hsv<T>, T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Xyz<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Hwb<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Hsv<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Alpha<Lab<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Yxy<T>, T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Alpha<Yxy<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Alpha<Hsv<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Rgb<T>, T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Hsl<T>, T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Luma<T>, T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Luma<T> where
T: Float,
[src]
T: Float,
impl<T> From<Lab<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Lch<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Lab<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Alpha<Hwb<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Hwb<T>, T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Alpha<Rgb<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Hsl<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Alpha<Xyz<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Color<T>> for Xyz<T> where
T: Float,
[src]
T: Float,
impl<T> From<GammaRgb<T>> for Color<T> where
T: Float,
[src]
T: Float,
impl<T> Shade for Color<T> where
T: Float,
[src]
T: Float,
type Scalar = T
The type of the lighten/darken amount.
fn lighten(&self, amount: T) -> Color<T>
[src]
fn darken(&self, amount: Self::Scalar) -> Self
[src]
Darken the color by amount
.
impl<T> Debug for Color<T> where
T: Debug + Float,
[src]
T: Debug + Float,
impl<T> Copy for Color<T> where
T: Copy + Float,
[src]
T: Copy + Float,
impl<T> Mix for Color<T> where
T: Float,
[src]
T: Float,
type Scalar = T
The type of the mixing factor.
fn mix(&self, other: &Color<T>, factor: T) -> Color<T>
[src]
impl<T> Hue for Color<T> where
T: Float,
[src]
T: Float,
fn with_hue(&self, hue: LabHue<T>) -> Color<T>
[src]
fn shift_hue(&self, amount: LabHue<T>) -> Color<T>
[src]
impl<T> Blend for Color<T> where
T: Float,
[src]
T: Float,
type Color = Rgb<T>
The core color type. Typically Self
for color types without alpha.
fn into_premultiplied(self) -> PreAlpha<Rgb<T>, T>
[src]
fn from_premultiplied(color: PreAlpha<Rgb<T>, T>) -> Color<T>
[src]
fn blend<F>(self, destination: Self, blend_function: F) -> Self where
F: BlendFunction<Self::Color>,
[src]
F: BlendFunction<Self::Color>,
Blend self, as the source color, with destination
, using blend_function
. Anything that implements BlendFunction
is acceptable, including functions and closures. Read more
fn over(self, other: Self) -> Self
[src]
Place self
over other
. This is the good old common alpha composition equation. Read more
fn inside(self, other: Self) -> Self
[src]
Results in the parts of self
that overlaps the visible parts of other
. Read more
fn outside(self, other: Self) -> Self
[src]
Results in the parts of self
that lies outside the visible parts of other
. Read more
fn atop(self, other: Self) -> Self
[src]
Place self
over only the visible parts of other
.
fn xor(self, other: Self) -> Self
[src]
Results in either self
or other
, where they do not overlap.
fn plus(self, other: Self) -> Self
[src]
Add self
and other
. This uses the alpha component to regulate the effect, so it's not just plain component wise addition. Read more
fn multiply(self, other: Self) -> Self
[src]
Multiply self
with other
. This uses the alpha component to regulate the effect, so it's not just plain component wise multiplication. Read more
fn screen(self, other: Self) -> Self
[src]
Make a color which is at least as light as self
or other
.
fn overlay(self, other: Self) -> Self
[src]
Multiply self
or other
if other is dark, or screen them if other
is light. This results in an S curve. Read more
fn darken(self, other: Self) -> Self
[src]
Return the darkest parts of self
and other
.
fn lighten(self, other: Self) -> Self
[src]
Return the lightest parts of self
and other
.
fn dodge(self, other: Self) -> Self
[src]
Lighten other
to reflect self
. Results in other
if self
is black. Read more
fn burn(self, other: Self) -> Self
[src]
Darken other
to reflect self
. Results in other
if self
is white. Read more
fn hard_light(self, other: Self) -> Self
[src]
Multiply self
or other
if other is dark, or screen them if self
is light. This is similar to overlay
, but depends on self
instead of other
. Read more
fn soft_light(self, other: Self) -> Self
[src]
Lighten other
if self
is light, or darken other
as if it's burned if self
is dark. The effect is increased if the components of self
is further from 0.5. Read more
fn difference(self, other: Self) -> Self
[src]
Return the absolute difference between self
and other
. It's basically abs(self - other)
, but regulated by the alpha component. Read more
fn exclusion(self, other: Self) -> Self
[src]
Similar to difference
, but appears to result in a lower contrast. other
is inverted if self
is white, and preserved if self
is black. Read more
impl<T> Saturate for Color<T> where
T: Float,
[src]
T: Float,
type Scalar = T
The type of the (de)saturation factor.
fn saturate(&self, factor: T) -> Color<T>
[src]
fn desaturate(&self, factor: Self::Scalar) -> Self
[src]
Decrease the saturation by factor
.
impl<T> GetHue for Color<T> where
T: Float,
[src]
T: Float,
type Hue = LabHue<T>
The kind of hue unit this color space uses. Read more
fn get_hue(&self) -> Option<LabHue<T>>
[src]
impl<T> Clone for Color<T> where
T: Clone + Float,
[src]
T: Clone + Float,
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Content for T
[src]
fn ref_from_ptr(ptr: *mut c_void, size: usize) -> Option<*mut T>
[src]
fn is_size_suitable(size: usize) -> bool
[src]
fn indiv_size() -> usize
[src]
impl<T> SafeBorrow<T> for T
[src]
impl<T> Erased for T
impl<S> FromSample<S> for S
[src]
fn from_sample_(s: S) -> S
[src]
impl<T, U> ToSample<U> for T where
U: FromSample<T>,
[src]
U: FromSample<T>,
fn to_sample_(self) -> U
[src]
impl<S, T> Duplex<S> for T where
T: FromSample<S> + ToSample<S>,
[src]
T: FromSample<S> + ToSample<S>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.