Type Alias palette::luma::SrgbLuma

source ·
pub type SrgbLuma<T = f32> = Luma<Srgb, T>;
Expand description

sRGB encoded luminance.

Aliased Type§

struct SrgbLuma<T = f32> {
    pub luma: T,
    pub standard: PhantomData<Srgb>,
}

Fields§

§luma: T

The lightness of the color. 0.0 is black and 1.0 is white.

§standard: PhantomData<Srgb>

The kind of RGB standard. sRGB is the default.

Implementations

source§

impl<S, T> Luma<S, T>
where T: Component, S: LumaStandard,

source

pub fn new(luma: T) -> Luma<S, T>

Create a luminance color.

source

pub fn into_format<U: Component>(self) -> Luma<S, U>

Convert into another component type.

source

pub fn from_format<U: Component>(color: Luma<S, U>) -> Self

Convert from another component type.

source

pub fn into_components(self) -> (T,)

Convert to a (luma,) tuple.

source

pub fn from_components((luma): (T,)) -> Self

Convert from a (luma,) tuple.

source§

impl<S, T> Luma<S, T>
where T: Component + Float, S: LumaStandard,

source

pub fn into_linear(self) -> Luma<Linear<S::WhitePoint>, T>

Convert the color to linear luminance.

source

pub fn from_linear(color: Luma<Linear<S::WhitePoint>, T>) -> Luma<S, T>

Convert linear luminance to nonlinear luminance.

source

pub fn into_encoding<St: LumaStandard<WhitePoint = S::WhitePoint>>( self ) -> Luma<St, T>

Convert the color to a different encoding.

source

pub fn from_encoding<St: LumaStandard<WhitePoint = S::WhitePoint>>( color: Luma<St, T> ) -> Luma<S, T>

Convert luminance from a different encoding.

Trait Implementations

source§

impl<S, T> From<Alpha<Lab<<S as LumaStandard>::WhitePoint, T>, T>> for Luma<S, T>

source§

fn from(color: Alpha<Lab<S::WhitePoint, T>, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T, _S> From<Alpha<Hwb<_S, T>, T>> for Luma<S, T>
where T: Component + Component + _FloatTrait, S: LumaStandard, _S: RgbSpace<WhitePoint = S::WhitePoint>,

source§

fn from(color: Alpha<Hwb<_S, T>, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> Pixel<T> for Luma<S, T>
where T: Component, S: LumaStandard,

source§

const CHANNELS: usize = 1usize

The number of color channels.
source§

fn as_raw<P: RawPixel<T> + ?Sized>(&self) -> &P

Cast as a reference to raw color components.
source§

fn as_raw_mut<P: RawPixel<T> + ?Sized>(&mut self) -> &mut P

Cast as a mutable reference to raw color components.
source§

fn into_raw<P: RawPixelSized<T>>(self) -> P

Convert from raw color components.
source§

fn from_raw<P: RawPixel<T> + ?Sized>(pixel: &P) -> &Self

Cast from a reference to raw color components.
source§

fn from_raw_mut<P: RawPixel<T> + ?Sized>(pixel: &mut P) -> &mut Self

Cast from a mutable reference to raw color components.
source§

fn from_raw_slice(slice: &[T]) -> &[Self]

Cast a slice of raw color components to a slice of colors. Read more
source§

fn from_raw_slice_mut(slice: &mut [T]) -> &mut [Self]

Cast a mutable slice of raw color components to a mutable slice of colors. Read more
source§

fn into_raw_slice(slice: &[Self]) -> &[T]

Cast a slice of colors to a slice of raw color components. Read more
source§

fn into_raw_slice_mut(slice: &mut [Self]) -> &mut [T]

Cast a mutable slice of colors to a mutable slice of raw color components. Read more
source§

impl<S, T> Mul for Luma<S, T>
where T: Component + Mul, S: LumaStandard<TransferFn = LinearFn>, <T as Mul>::Output: Component,

§

type Output = Luma<S, <T as Mul>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, other: Luma<S, T>) -> Self::Output

Performs the * operation. Read more
source§

impl<S, T, _S> From<Hsv<_S, T>> for Luma<S, T>
where T: Component + Component + _FloatTrait, S: LumaStandard, _S: RgbSpace<WhitePoint = S::WhitePoint>,

source§

fn from(color: Hsv<_S, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T, _S> From<Alpha<Luma<_S, T>, T>> for Luma<S, T>
where T: Component + Component + _FloatTrait, S: LumaStandard, _S: LumaStandard<WhitePoint = S::WhitePoint>,

source§

fn from(color: Alpha<Luma<_S, T>, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> From<Yxy<<S as LumaStandard>::WhitePoint, T>> for Luma<S, T>
where S: LumaStandard, T: Component + Float,

source§

fn from(color: Yxy<S::WhitePoint, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> UpperHex for Luma<S, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl<S, T> Blend for Luma<S, T>
where T: Component + Float, S: LumaStandard<TransferFn = LinearFn>,

§

type Color = Luma<S, T>

The core color type. Typically Self for color types without alpha.
source§

fn into_premultiplied(self) -> PreAlpha<Luma<S, T>, T>

Convert the color to premultiplied alpha.
source§

fn from_premultiplied(color: PreAlpha<Luma<S, T>, T>) -> Self

Convert the color from premultiplied alpha.
source§

fn blend<F>(self, destination: Self, blend_function: F) -> Self
where 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
source§

fn over(self, other: Self) -> Self

Place self over other. This is the good old common alpha composition equation.
source§

fn inside(self, other: Self) -> Self

Results in the parts of self that overlaps the visible parts of other.
source§

fn outside(self, other: Self) -> Self

Results in the parts of self that lies outside the visible parts of other.
source§

fn atop(self, other: Self) -> Self

Place self over only the visible parts of other.
source§

fn xor(self, other: Self) -> Self

Results in either self or other, where they do not overlap.
source§

fn plus(self, other: Self) -> Self

Add self and other. This uses the alpha component to regulate the effect, so it’s not just plain component wise addition.
source§

fn multiply(self, other: Self) -> Self

Multiply self with other. This uses the alpha component to regulate the effect, so it’s not just plain component wise multiplication.
source§

fn screen(self, other: Self) -> Self

Make a color which is at least as light as self or other.
source§

fn overlay(self, other: Self) -> Self

Multiply self or other if other is dark, or screen them if other is light. This results in an S curve.
source§

fn darken(self, other: Self) -> Self

Return the darkest parts of self and other.
source§

fn lighten(self, other: Self) -> Self

Return the lightest parts of self and other.
source§

fn dodge(self, other: Self) -> Self

Lighten other to reflect self. Results in other if self is black.
source§

fn burn(self, other: Self) -> Self

Darken other to reflect self. Results in other if self is white.
source§

fn hard_light(self, other: Self) -> Self

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.
source§

fn soft_light(self, other: Self) -> Self

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.
source§

fn difference(self, other: Self) -> Self

Return the absolute difference between self and other. It’s basically abs(self - other), but regulated by the alpha component.
source§

fn exclusion(self, other: Self) -> Self

Similar to difference, but appears to result in a lower contrast. other is inverted if self is white, and preserved if self is black.
source§

impl<S, T> LowerHex for Luma<S, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter.
source§

impl<S, T> MulAssign<T> for Luma<S, T>
where T: Component + MulAssign, S: LumaStandard<TransferFn = LinearFn>,

source§

fn mul_assign(&mut self, c: T)

Performs the *= operation. Read more
source§

impl<S, T> From<Alpha<Xyz<<S as LumaStandard>::WhitePoint, T>, T>> for Luma<S, T>

source§

fn from(color: Alpha<Xyz<S::WhitePoint, T>, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T, _S> From<Hwb<_S, T>> for Luma<S, T>
where T: Component + Component + _FloatTrait, S: LumaStandard, _S: RgbSpace<WhitePoint = S::WhitePoint>,

source§

fn from(color: Hwb<_S, T>) -> Self

Converts to this type from the input type.
source§

impl<S: LumaStandard, T: Component> Into<(T,)> for Luma<S, T>

source§

fn into(self) -> (T,)

Converts this type into the (usually inferred) input type.
source§

impl<S, T> AddAssign<T> for Luma<S, T>
where T: Component + AddAssign, S: LumaStandard<TransferFn = LinearFn>,

source§

fn add_assign(&mut self, c: T)

Performs the += operation. Read more
source§

impl<S, T> Sub<T> for Luma<S, T>
where T: Component + Sub, S: LumaStandard<TransferFn = LinearFn>, <T as Sub>::Output: Component,

§

type Output = Luma<S, <T as Sub>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, c: T) -> Self::Output

Performs the - operation. Read more
source§

impl<S: LumaStandard, T: Component> From<(T,)> for Luma<S, T>

source§

fn from(components: (T,)) -> Self

Converts to this type from the input type.
source§

impl<S, T> UlpsEq for Luma<S, T>

source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of ApproxEq::ulps_eq.
source§

impl<S, T> Add<T> for Luma<S, T>
where T: Component + Add, S: LumaStandard<TransferFn = LinearFn>, <T as Add>::Output: Component,

§

type Output = Luma<S, <T as Add>::Output>

The resulting type after applying the + operator.
source§

fn add(self, c: T) -> Self::Output

Performs the + operation. Read more
source§

impl<S, T, _S> From<Alpha<Hsv<_S, T>, T>> for Luma<S, T>
where T: Component + Component + _FloatTrait, S: LumaStandard, _S: RgbSpace<WhitePoint = S::WhitePoint>,

source§

fn from(color: Alpha<Hsv<_S, T>, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> Serialize for Luma<S, T>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<S, T, _S> From<Alpha<Rgb<_S, T>, T>> for Luma<S, T>
where T: Component + Component + _FloatTrait, S: LumaStandard, _S: RgbStandard, _S::Space: RgbSpace<WhitePoint = S::WhitePoint>,

source§

fn from(color: Alpha<Rgb<_S, T>, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> FromColor<<S as LumaStandard>::WhitePoint, T> for Luma<S, T>

source§

fn from_xyz(color: Xyz<S::WhitePoint, T>) -> Self

Convert from XYZ color space
source§

fn from_yxy(color: Yxy<S::WhitePoint, T>) -> Self

Convert from Yxy color space
source§

fn from_luma(color: Luma<Linear<S::WhitePoint>, T>) -> Self

Convert from Luma
source§

fn from_lab(inp: Lab<Wp, T>) -> Self

Convert from L*a*b* color space
source§

fn from_lch(inp: Lch<Wp, T>) -> Self

Convert from L*C*h° color space
source§

fn from_rgb<S: RgbSpace<WhitePoint = Wp>>(inp: Rgb<Linear<S>, T>) -> Self

Convert from RGB color space
source§

fn from_hsl<S: RgbSpace<WhitePoint = Wp>>(inp: Hsl<S, T>) -> Self

Convert from HSL color space
source§

fn from_hsv<S: RgbSpace<WhitePoint = Wp>>(inp: Hsv<S, T>) -> Self

Convert from HSV color space
source§

fn from_hwb<S: RgbSpace<WhitePoint = Wp>>(inp: Hwb<S, T>) -> Self

Convert from HWB color space
source§

impl<S, T> SubAssign for Luma<S, T>
where T: Component + SubAssign, S: LumaStandard<TransferFn = LinearFn>,

source§

fn sub_assign(&mut self, other: Luma<S, T>)

Performs the -= operation. Read more
source§

impl<S, T> From<Alpha<Yxy<<S as LumaStandard>::WhitePoint, T>, T>> for Luma<S, T>

source§

fn from(color: Alpha<Yxy<S::WhitePoint, T>, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> Default for Luma<S, T>
where T: Component, S: LumaStandard,

source§

fn default() -> Luma<S, T>

Returns the “default value” for a type. Read more
source§

impl<S, T> Add for Luma<S, T>
where T: Component + Add, S: LumaStandard<TransferFn = LinearFn>, <T as Add>::Output: Component,

§

type Output = Luma<S, <T as Add>::Output>

The resulting type after applying the + operator.
source§

fn add(self, other: Luma<S, T>) -> Self::Output

Performs the + operation. Read more
source§

impl<S, T> Limited for Luma<S, T>
where T: Component, S: LumaStandard,

source§

fn is_valid(&self) -> bool

Check if the color’s components are within the expected ranges.
source§

fn clamp(&self) -> Luma<S, T>

Return a new color where the components has been clamped to the nearest valid values.
source§

fn clamp_self(&mut self)

Clamp the color’s components to the nearest valid values.
source§

impl<S, T> Clone for Luma<S, T>
where T: Component, S: LumaStandard,

source§

fn clone(&self) -> Luma<S, T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S, T> Div<T> for Luma<S, T>
where T: Component + Div, S: LumaStandard<TransferFn = LinearFn>, <T as Div>::Output: Component,

§

type Output = Luma<S, <T as Div>::Output>

The resulting type after applying the / operator.
source§

fn div(self, c: T) -> Self::Output

Performs the / operation. Read more
source§

impl<S, Wp, T> IntoColor<Wp, T> for Luma<S, T>
where S: LumaStandard<WhitePoint = Wp>, T: Component + Float, Wp: WhitePoint,

source§

fn into_xyz(self) -> Xyz<Wp, T>

Convert into XYZ space
source§

fn into_yxy(self) -> Yxy<Wp, T>

Convert into Yxy color space
source§

fn into_luma(self) -> Luma<Linear<Wp>, T>

Convert into Luma
source§

fn into_lab(self) -> Lab<Wp, T>

Convert into L*a*b* color space
source§

fn into_lch(self) -> Lch<Wp, T>

Convert into L*C*h° color space
source§

fn into_rgb<S: RgbSpace<WhitePoint = Wp>>(self) -> Rgb<Linear<S>, T>

Convert into RGB color space.
source§

fn into_hsl<S: RgbSpace<WhitePoint = Wp>>(self) -> Hsl<S, T>

Convert into HSL color space
source§

fn into_hsv<S: RgbSpace<WhitePoint = Wp>>(self) -> Hsv<S, T>

Convert into HSV color space
source§

fn into_hwb<S: RgbSpace<WhitePoint = Wp>>(self) -> Hwb<S, T>

Convert into HWB color space
source§

impl<S, T> Mul<T> for Luma<S, T>
where T: Component + Mul, S: LumaStandard<TransferFn = LinearFn>, <T as Mul>::Output: Component,

§

type Output = Luma<S, <T as Mul>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, c: T) -> Self::Output

Performs the * operation. Read more
source§

impl<S, T> AbsDiffEq for Luma<S, T>

§

type Epsilon = <T as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of ApproxEq::abs_diff_eq.
source§

impl<S, T> DivAssign for Luma<S, T>
where T: Component + DivAssign, S: LumaStandard<TransferFn = LinearFn>,

source§

fn div_assign(&mut self, other: Luma<S, T>)

Performs the /= operation. Read more
source§

impl<S, T> From<Alpha<Lch<<S as LumaStandard>::WhitePoint, T>, T>> for Luma<S, T>

source§

fn from(color: Alpha<Lch<S::WhitePoint, T>, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> DivAssign<T> for Luma<S, T>
where T: Component + DivAssign, S: LumaStandard<TransferFn = LinearFn>,

source§

fn div_assign(&mut self, c: T)

Performs the /= operation. Read more
source§

impl<S, T> From<Lch<<S as LumaStandard>::WhitePoint, T>> for Luma<S, T>

source§

fn from(color: Lch<S::WhitePoint, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> RelativeEq for Luma<S, T>

source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of ApproxEq::relative_eq.
source§

impl<S, T> StructuralPartialEq for Luma<S, T>
where T: Component, S: LumaStandard,

source§

impl<S, T> ComponentWise for Luma<S, T>
where T: Component, S: LumaStandard,

§

type Scalar = T

The scalar type for color components.
source§

fn component_wise<F: FnMut(T, T) -> T>( &self, other: &Luma<S, T>, f: F ) -> Luma<S, T>

Perform a binary operation on this and an other color.
source§

fn component_wise_self<F: FnMut(T) -> T>(&self, f: F) -> Luma<S, T>

Perform a unary operation on this color.
source§

impl<S, T> Mix for Luma<S, T>
where T: Component + Float, S: LumaStandard<TransferFn = LinearFn>,

§

type Scalar = T

The type of the mixing factor.
source§

fn mix(&self, other: &Luma<S, T>, factor: T) -> Luma<S, T>

Mix the color with an other color, by factor. Read more
source§

impl<S, T, _S> From<Rgb<_S, T>> for Luma<S, T>
where T: Component + Component + _FloatTrait, S: LumaStandard, _S: RgbStandard, _S::Space: RgbSpace<WhitePoint = S::WhitePoint>,

source§

fn from(color: Rgb<_S, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> PartialEq for Luma<S, T>

source§

fn eq(&self, other: &Luma<S, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<S, T> Copy for Luma<S, T>
where T: Component, S: LumaStandard,

source§

impl<S, T, _S> From<Alpha<Hsl<_S, T>, T>> for Luma<S, T>
where T: Component + Component + _FloatTrait, S: LumaStandard, _S: RgbSpace<WhitePoint = S::WhitePoint>,

source§

fn from(color: Alpha<Hsl<_S, T>, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> SubAssign<T> for Luma<S, T>
where T: Component + SubAssign, S: LumaStandard<TransferFn = LinearFn>,

source§

fn sub_assign(&mut self, c: T)

Performs the -= operation. Read more
source§

impl<S, T, P> AsRef<P> for Luma<S, T>
where T: Component, S: LumaStandard, P: RawPixel<T> + ?Sized,

source§

fn as_ref(&self) -> &P

Convert to a raw pixel format.

use palette::SrgbLuma;

let luma = SrgbLuma::new(100);
let raw: &[u8] = luma.as_ref();

assert_eq!(raw[0], 100);
source§

impl<S, T> Shade for Luma<S, T>
where T: Component + Float, S: LumaStandard<TransferFn = LinearFn>,

§

type Scalar = T

The type of the lighten/darken amount.
source§

fn lighten(&self, amount: T) -> Luma<S, T>

Lighten the color by amount.
source§

fn darken(&self, amount: Self::Scalar) -> Self

Darken the color by amount.
source§

impl<S, T> Div for Luma<S, T>
where T: Component + Div, S: LumaStandard<TransferFn = LinearFn>, <T as Div>::Output: Component,

§

type Output = Luma<S, <T as Div>::Output>

The resulting type after applying the / operator.
source§

fn div(self, other: Luma<S, T>) -> Self::Output

Performs the / operation. Read more
source§

impl<S, T, P> AsMut<P> for Luma<S, T>
where T: Component, S: LumaStandard, P: RawPixel<T> + ?Sized,

source§

fn as_mut(&mut self) -> &mut P

Convert to a raw pixel format.

use palette::SrgbLuma;

let mut luma = SrgbLuma::new(100);
{
    let raw: &mut [u8] = luma.as_mut();
    raw[0] = 5;
}

assert_eq!(luma.luma, 5);
source§

impl<S, T> Sub for Luma<S, T>
where T: Component + Sub, S: LumaStandard<TransferFn = LinearFn>, <T as Sub>::Output: Component,

§

type Output = Luma<S, <T as Sub>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, other: Luma<S, T>) -> Self::Output

Performs the - operation. Read more
source§

impl<S, T> From<Lab<<S as LumaStandard>::WhitePoint, T>> for Luma<S, T>

source§

fn from(color: Lab<S::WhitePoint, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T> MulAssign for Luma<S, T>
where T: Component + MulAssign, S: LumaStandard<TransferFn = LinearFn>,

source§

fn mul_assign(&mut self, other: Luma<S, T>)

Performs the *= operation. Read more
source§

impl<S, T> AddAssign for Luma<S, T>
where T: Component + AddAssign, S: LumaStandard<TransferFn = LinearFn>,

source§

fn add_assign(&mut self, other: Luma<S, T>)

Performs the += operation. Read more
source§

impl<S, T> Debug for Luma<S, T>
where T: Component + Debug, S: LumaStandard + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, S, T> Deserialize<'de> for Luma<S, T>
where T: Component + Deserialize<'de>, S: LumaStandard,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<S, T> From<Xyz<<S as LumaStandard>::WhitePoint, T>> for Luma<S, T>
where S: LumaStandard, T: Component + Float,

source§

fn from(color: Xyz<S::WhitePoint, T>) -> Self

Converts to this type from the input type.
source§

impl<S, T, _S> From<Hsl<_S, T>> for Luma<S, T>
where T: Component + Component + _FloatTrait, S: LumaStandard, _S: RgbSpace<WhitePoint = S::WhitePoint>,

source§

fn from(color: Hsl<_S, T>) -> Self

Converts to this type from the input type.