Add Luma struct (#1154)

* Make Luma usable for MaskImageNode
This commit is contained in:
Dennis Kobert
2023-04-23 19:42:34 +02:00
committed by GitHub
parent 72d8fe6735
commit c8b86d4530
3 changed files with 30 additions and 1 deletions

View File

@@ -14,6 +14,34 @@ use bytemuck::{Pod, Zeroable};
use super::{Alpha, AssociatedAlpha, Luminance, Pixel, Rec709Primaries, RGB, SRGB};
#[repr(C)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "std", derive(specta::Type))]
#[derive(Debug, Default, Clone, Copy, PartialEq, DynAny, Pod, Zeroable)]
pub struct Luma(pub f32);
impl Luminance for Luma {
type LuminanceChannel = f32;
fn luminance(&self) -> f32 {
self.0
}
}
impl RGB for Luma {
type ColorChannel = f32;
fn red(&self) -> f32 {
self.0
}
fn green(&self) -> f32 {
self.0
}
fn blue(&self) -> f32 {
self.0
}
}
impl Pixel for Luma {}
/// Structure that represents a color.
/// Internally alpha is stored as `f32` that ranges from `0.0` (transparent) to `1.0` (opaque).
/// The other components (RGB) are stored as `f32` that range from `0.0` up to `f32::MAX`,