palette/
luma.rs

1//! Types for luma and luminance (grayscale) values.
2
3pub mod channels;
4#[allow(clippy::module_inception)]
5mod luma;
6
7use crate::encoding::{Gamma, Linear, Srgb};
8use crate::white_point::D65;
9
10pub use self::luma::{Iter, Luma, Lumaa};
11
12/// sRGB encoded luminance.
13pub type SrgbLuma<T = f32> = Luma<Srgb, T>;
14/// sRGB encoded luminance with an alpha component.
15pub type SrgbLumaa<T = f32> = Lumaa<Srgb, T>;
16
17/// Linear luminance.
18#[doc(alias = "linear")]
19pub type LinLuma<Wp = D65, T = f32> = Luma<Linear<Wp>, T>;
20/// Linear luminance with an alpha component.
21#[doc(alias = "linear")]
22pub type LinLumaa<Wp = D65, T = f32> = Lumaa<Linear<Wp>, T>;
23
24/// Gamma 2.2 encoded luminance.
25pub type GammaLuma<T = f32> = Luma<Gamma<D65>, T>;
26/// Gamma 2.2 encoded luminance with an alpha component.
27pub type GammaLumaa<T = f32> = Lumaa<Gamma<D65>, T>;
28
29/// A white point and a transfer function.
30pub trait LumaStandard {
31    /// The white point of the color space.
32    type WhitePoint;
33
34    /// The transfer function for the luminance component.
35    type TransferFn;
36}
37
38impl<Wp, Tf> LumaStandard for (Wp, Tf) {
39    type WhitePoint = Wp;
40    type TransferFn = Tf;
41}
42
43/// A packed representation of Luma+Alpha in LA order.
44pub type PackedLumaa<P = u16> = crate::cast::Packed<channels::La, P>;
45
46/// A packed representation of Luma+Alpha in AL order.
47pub type PackedAluma<P = u16> = crate::cast::Packed<channels::Al, P>;