use core::fmt;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct ColAlpha<T> {
pub col: T,
pub alpha: f32,
}
impl<T: fmt::Display> fmt::Display for ColAlpha<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}, Alpha: {}", self.col, self.alpha)
}
}
macro_rules! impl_bytemuck {
($($inner:ident),+) => {
$(
unsafe impl bytemuck::Zeroable for $inner {}
unsafe impl bytemuck::Pod for $inner {}
unsafe impl bytemuck::Zeroable for ColAlpha<$inner> {}
unsafe impl bytemuck::Pod for ColAlpha<$inner> {}
)+
}
}
impl_bytemuck!(Rgb, ICtCp, Xyz, Lab, LCh);
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Rgb {
pub r: f32,
pub g: f32,
pub b: f32,
}
impl fmt::Display for Rgb {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "R: {}, G: {}, B: {}", self.r, self.g, self.b)
}
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct ICtCp {
pub i: f32,
pub ct: f32,
pub cp: f32,
}
impl fmt::Display for ICtCp {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "I: {}, Ct: {}, Cp: {}", self.i, self.ct, self.cp)
}
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Xyz {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl fmt::Display for Xyz {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "X: {}, Y: {}, Z: {}", self.x, self.y, self.z)
}
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Lab {
pub l: f32,
pub a: f32,
pub b: f32,
}
impl fmt::Display for Lab {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "L: {}, a: {}, b: {}", self.l, self.a, self.b)
}
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct LCh {
pub l: f32,
pub c: f32,
pub h: f32,
}
impl fmt::Display for LCh {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "L: {}, C: {}, h: {}", self.l, self.c, self.h)
}
}