Struct nannou::prelude::Rgb
[−]
[src]
pub struct Rgb<T = f32> where
T: Float, { pub red: T, pub green: T, pub blue: T, }
Linear RGB.
RGB is probably the most common color space, when it comes to computer graphics, and it's defined as an additive mixture of red, green and blue light, where gray scale colors are created when these three channels are equal in strength. This particular RGB type is based on the ITU-R BT.709 primaries, which makes it a linear version of sRGB.
Conversions and operations on this color space assumes that it's linear,
meaning that gamma correction is required when converting to and from a
displayable RGB, such as sRGB. See the pixel
module
for encoding types.
Fields
red: T
The amount of red light, where 0.0 is no red light and 1.0 is the highest displayable amount.
green: T
The amount of green light, where 0.0 is no green light and 1.0 is the highest displayable amount.
blue: T
The amount of blue light, where 0.0 is no blue light and 1.0 is the highest displayable amount.
Methods
impl<T> Rgb<T> where
T: Float,
[src]
T: Float,
pub fn new(red: T, green: T, blue: T) -> Rgb<T>
[src]
Linear RGB.
pub fn new_u8(red: u8, green: u8, blue: u8) -> Rgb<T>
[src]
Linear RGB from 8 bit values.
pub fn from_pixel<P>(pixel: &P) -> Rgb<T> where
P: RgbPixel<T>,
[src]
P: RgbPixel<T>,
Linear RGB from a linear pixel value.
pub fn to_pixel<P>(&self) -> P where
P: RgbPixel<T>,
[src]
P: RgbPixel<T>,
Convert to a linear RGB pixel. Rgb
is already assumed to be linear,
so the components will just be clamped to [0.0, 1.0] before conversion.
use palette::Rgb; let c = Rgb::new(0.5, 0.3, 0.1); assert_eq!((c.red, c.green, c.blue), c.to_pixel()); assert_eq!((0.5, 0.3, 0.1), c.to_pixel());
Trait Implementations
impl<T> Default for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> Shade for Rgb<T> where
T: Float,
[src]
T: Float,
type Scalar = T
The type of the lighten/darken amount.
fn lighten(&self, amount: T) -> Rgb<T>
[src]
Lighten the color by amount
.
fn darken(&self, amount: Self::Scalar) -> Self
[src]
Darken the color by amount
.
impl<T> Sub<Rgb<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
type Output = Rgb<T>
The resulting type after applying the -
operator.
fn sub(self, other: Rgb<T>) -> Rgb<T>
[src]
Performs the -
operation.
impl<T> Sub<T> for Rgb<T> where
T: Float,
[src]
T: Float,
type Output = Rgb<T>
The resulting type after applying the -
operator.
fn sub(self, c: T) -> Rgb<T>
[src]
Performs the -
operation.
impl<T> Mix for Rgb<T> where
T: Float,
[src]
T: Float,
type Scalar = T
The type of the mixing factor.
fn mix(&self, other: &Rgb<T>, factor: T) -> Rgb<T>
[src]
Mix the color with an other color, by factor
. Read more
impl<T> ApproxEq for Rgb<T> where
T: ApproxEq + Float,
<T as ApproxEq>::Epsilon: Copy,
<T as ApproxEq>::Epsilon: Float,
[src]
T: ApproxEq + Float,
<T as ApproxEq>::Epsilon: Copy,
<T as ApproxEq>::Epsilon: Float,
type Epsilon = <T as ApproxEq>::Epsilon
Used for specifying relative comparisons.
fn default_epsilon() -> <Rgb<T> as ApproxEq>::Epsilon
[src]
The default tolerance to use when testing values that are close together. Read more
fn default_max_relative() -> <Rgb<T> as ApproxEq>::Epsilon
[src]
The default relative tolerance for testing values that are far-apart. Read more
fn default_max_ulps() -> u32
[src]
The default ULPs to tolerate when testing values that are far-apart. Read more
fn relative_eq(
&self,
other: &Rgb<T>,
epsilon: <Rgb<T> as ApproxEq>::Epsilon,
max_relative: <Rgb<T> as ApproxEq>::Epsilon
) -> bool
[src]
&self,
other: &Rgb<T>,
epsilon: <Rgb<T> as ApproxEq>::Epsilon,
max_relative: <Rgb<T> as ApproxEq>::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
fn ulps_eq(
&self,
other: &Rgb<T>,
epsilon: <Rgb<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
[src]
&self,
other: &Rgb<T>,
epsilon: <Rgb<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
A test for equality that uses units in the last place (ULP) if the values are far apart.
fn relative_ne(
&self,
other: &Rgb<T>,
epsilon: <Rgb<T> as ApproxEq>::Epsilon,
max_relative: <Rgb<T> as ApproxEq>::Epsilon
) -> bool
[src]
&self,
other: &Rgb<T>,
epsilon: <Rgb<T> as ApproxEq>::Epsilon,
max_relative: <Rgb<T> as ApproxEq>::Epsilon
) -> bool
The inverse of ApproxEq::relative_eq
.
fn ulps_ne(
&self,
other: &Rgb<T>,
epsilon: <Rgb<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
[src]
&self,
other: &Rgb<T>,
epsilon: <Rgb<T> as ApproxEq>::Epsilon,
max_ulps: u32
) -> bool
The inverse of ApproxEq::ulps_eq
.
impl<T> GetHue for Rgb<T> where
T: Float,
[src]
T: Float,
type Hue = RgbHue<T>
The kind of hue unit this color space uses. Read more
fn get_hue(&self) -> Option<RgbHue<T>>
[src]
Calculate a hue if possible. Read more
impl<T> Mul<Rgb<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
type Output = Rgb<T>
The resulting type after applying the *
operator.
fn mul(self, other: Rgb<T>) -> Rgb<T>
[src]
Performs the *
operation.
impl<T> Mul<T> for Rgb<T> where
T: Float,
[src]
T: Float,
type Output = Rgb<T>
The resulting type after applying the *
operator.
fn mul(self, c: T) -> Rgb<T>
[src]
Performs the *
operation.
impl<T> ComponentWise for Rgb<T> where
T: Float,
[src]
T: Float,
type Scalar = T
The scalar type for color components.
fn component_wise<F>(&self, other: &Rgb<T>, f: F) -> Rgb<T> where
F: FnMut(T, T) -> T,
[src]
F: FnMut(T, T) -> T,
Perform a binary operation on this and an other color.
fn component_wise_self<F>(&self, f: F) -> Rgb<T> where
F: FnMut(T) -> T,
[src]
F: FnMut(T) -> T,
Perform a unary operation on this color.
impl<T> Copy for Rgb<T> where
T: Copy + Float,
[src]
T: Copy + Float,
impl<T> Div<Rgb<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
type Output = Rgb<T>
The resulting type after applying the /
operator.
fn div(self, other: Rgb<T>) -> Rgb<T>
[src]
Performs the /
operation.
impl<T> Div<T> for Rgb<T> where
T: Float,
[src]
T: Float,
type Output = Rgb<T>
The resulting type after applying the /
operator.
fn div(self, c: T) -> Rgb<T>
[src]
Performs the /
operation.
impl<T> PartialEq<Rgb<T>> for Rgb<T> where
T: PartialEq<T> + Float,
[src]
T: PartialEq<T> + Float,
fn eq(&self, __arg_0: &Rgb<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Rgb<T>) -> bool
[src]
This method tests for !=
.
impl<T> From<Alpha<Luma<T>, T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Yxy<T>, T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Hsv<T>, T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Lab<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Alpha<Yxy<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Alpha<Hwb<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Alpha<Hsl<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Hwb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Lab<T>, T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Lch<T>, T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Alpha<Lch<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Hwb<T>, T>> for Rgb<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 Lch<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Alpha<Xyz<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Hwb<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Yxy<T> where
T: Float,
[src]
T: Float,
impl<T> From<Luma<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Lch<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Alpha<Luma<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Luma<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Alpha<Lab<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<GammaRgb<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Lab<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Xyz<T>, T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Hsv<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Hsl<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Xyz<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Rgb<T>, T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Alpha<Hsl<T>, 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<Rgb<T>> for Xyz<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Srgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Hsv<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Alpha<Hsv<T>, T> where
T: Float,
[src]
T: Float,
impl<T> From<Yxy<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Srgb<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
impl<T> From<Rgb<T>> for Hsl<T> where
T: Float,
[src]
T: Float,
impl<T> FromColor<T> for Rgb<T> where
T: Float,
[src]
T: Float,
fn from_xyz(xyz: Xyz<T>) -> Rgb<T>
[src]
Convert from XYZ color space
fn from_rgb(rgb: Rgb<T>) -> Rgb<T>
[src]
Convert from RGB color space
fn from_hsl(hsl: Hsl<T>) -> Rgb<T>
[src]
Convert from HSL color space
fn from_hsv(hsv: Hsv<T>) -> Rgb<T>
[src]
Convert from HSV color space
fn from_luma(luma: Luma<T>) -> Rgb<T>
[src]
Convert from Luma
fn from_yxy(inp: Yxy<T>) -> Self
[src]
Convert from Yxy color space
fn from_lab(inp: Lab<T>) -> Self
[src]
Convert from Lab* color space
fn from_lch(inp: Lch<T>) -> Self
[src]
Convert from LCh° color space
fn from_hwb(inp: Hwb<T>) -> Self
[src]
Convert from HWB color space
impl<T> Blend for Rgb<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]
Convert the color to premultiplied alpha.
fn from_premultiplied(color: PreAlpha<Rgb<T>, T>) -> Rgb<T>
[src]
Convert the color from premultiplied alpha.
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> Clone for Rgb<T> where
T: Clone + Float,
[src]
T: Clone + Float,
fn clone(&self) -> Rgb<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Add<T> for Rgb<T> where
T: Float,
[src]
T: Float,
type Output = Rgb<T>
The resulting type after applying the +
operator.
fn add(self, c: T) -> Rgb<T>
[src]
Performs the +
operation.
impl<T> Add<Rgb<T>> for Rgb<T> where
T: Float,
[src]
T: Float,
type Output = Rgb<T>
The resulting type after applying the +
operator.
fn add(self, other: Rgb<T>) -> Rgb<T>
[src]
Performs the +
operation.
impl<T> Limited for Rgb<T> where
T: Float,
[src]
T: Float,
fn is_valid(&self) -> bool
[src]
Check if the color's components are within the expected ranges.
fn clamp(&self) -> Rgb<T>
[src]
Return a new color where the components has been clamped to the nearest valid values. Read more
fn clamp_self(&mut self)
[src]
Clamp the color's components to the nearest valid values.
impl<T> IntoColor<T> for Rgb<T> where
T: Float,
[src]
T: Float,
fn into_xyz(self) -> Xyz<T>
[src]
Convert into XYZ space
fn into_yxy(self) -> Yxy<T>
[src]
Convert into Yxy color space
fn into_lab(self) -> Lab<T>
[src]
Convert into Lab* color space
fn into_lch(self) -> Lch<T>
[src]
Convert into LCh° color space
fn into_rgb(self) -> Rgb<T>
[src]
Convert into RGB color space.
fn into_hsl(self) -> Hsl<T>
[src]
Convert into HSL color space
fn into_hsv(self) -> Hsv<T>
[src]
Convert into HSV color space
fn into_luma(self) -> Luma<T>
[src]
Convert into Luma
fn into_hwb(self) -> Hwb<T>
[src]
Convert into HWB color space
impl<T> Debug for Rgb<T> where
T: Debug + Float,
[src]
T: Debug + Float,
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl<S> IntoRgba<S> for Rgb<S> where
S: Float + One,
[src]
S: Float + One,