colr-types 0.3.1

Color model ZSTs and marker traits for colr.
Documentation
//! Luma and luma+alpha color models.

use core::marker::PhantomData;

use crate::BackingStore;
use crate::primaries::Primaries;
use crate::transfer::TransferFunction;
use crate::{AlphaState, Straight};

/// Luma derived from an RGB space with primaries P and transfer function TF.
///
/// Luma Y' is the weighted sum of gamma-encoded RGB channels. The weights
/// are the Y row of the primaries' RGB-to-XYZ matrix, so they vary by primary
/// set.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Luma<P: Primaries, TF: TransferFunction>(PhantomData<(P, TF)>);

/// Luma with an alpha channel. Alpha state defaults to `Straight`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct LumaAlpha<P: Primaries, TF: TransferFunction, A: AlphaState = Straight>(
    PhantomData<(P, TF, A)>,
);

impl<P: Primaries, TF: TransferFunction> BackingStore<f32> for Luma<P, TF> {}
impl<P: Primaries, TF: TransferFunction, A: AlphaState> BackingStore<[f32; 2]>
    for LumaAlpha<P, TF, A>
{
}

#[cfg(feature = "glam")]
mod glam_impls {
    use super::*;
    impl<P: Primaries, TF: TransferFunction, A: AlphaState> BackingStore<glam::Vec2>
        for LumaAlpha<P, TF, A>
    {
    }
}