Type Alias palette::luma::Lumaa

source ·
pub type Lumaa<S = Srgb, T = f32> = Alpha<Luma<S, T>, T>;
Expand description

Luminance with an alpha component. See the Lumaa implementation in Alpha.

Aliased Type§

struct Lumaa<S = Srgb, T = f32> {
    pub color: Luma<S, T>,
    pub alpha: T,
}

Fields§

§color: Luma<S, T>

The color.

§alpha: T

The transparency component. 0.0 (or 0u8) is fully transparent and 1.0 (or 255u8) is fully opaque.

Implementations§

source§

impl<S> Lumaa<S, u8>

source

pub fn into_u16<O>(self) -> u16
where O: ComponentOrder<Lumaa<S, u8>, u16>,

Convert to a packed u16 with with a specific component order.

use palette::{luma, SrgbLumaa};

let integer = SrgbLumaa::new(96u8, 255).into_u16::<luma::channels::Al>();
assert_eq!(0xFF60, integer);

It’s also possible to use From and Into, which defaults to the 0xLLAA component order:

use palette::SrgbLumaa;

let integer = u16::from(SrgbLumaa::new(96u8, 255));
assert_eq!(0x60FF, integer);

See Packed for more details.

source

pub fn from_u16<O>(color: u16) -> Self
where O: ComponentOrder<Lumaa<S, u8>, u16>,

Convert from a packed u16 with a specific component order.

use palette::{luma, SrgbLumaa};

let luma = SrgbLumaa::from_u16::<luma::channels::Al>(0xFF60);
assert_eq!(SrgbLumaa::new(96u8, 255), luma);

It’s also possible to use From and Into, which defaults to the 0xLLAA component order:

use palette::SrgbLumaa;

let luma = SrgbLumaa::from(0x60FF);
assert_eq!(SrgbLumaa::new(96u8, 255), luma);

See Packed for more details.

Trait Implementations§

source§

impl<S, T, O, P> From<Packed<O, P>> for Lumaa<S, T>
where O: ComponentOrder<Lumaa<S, T>, P>,

source§

fn from(packed: Packed<O, P>) -> Self

Converts to this type from the input type.
source§

impl<S> From<u16> for Lumaa<S, u8>

source§

fn from(color: u16) -> Self

Converts to this type from the input type.