pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
pub cmyk: Option<[f32; 4]>,
}Expand description
An sRGB 8-bit color with pre-multiplied-independent alpha.
r, g, b, a are all in 0..=255 (linear 8-bit sRGB per channel,
straight / un-pre-multiplied alpha).
cmyk is None for sRGB-origin colors. When a color token was declared in
CMYK (cmyk(c,m,y,k)), this carries the original [c, m, y, k] percentages
(0.0..=100.0) so a future PDF backend can emit native DeviceCMYK; the
r/g/b channels then hold the naive device sRGB conversion. The PNG
renderer ignores cmyk entirely and paints with r/g/b/a.
Fields§
§r: u8§g: u8§b: u8§a: u8§cmyk: Option<[f32; 4]>Original CMYK channels [c, m, y, k] (percentages) when this color was
declared in CMYK; None for sRGB-origin colors. Skipped in JSON when
absent so existing sRGB scenes serialize byte-identically.
Implementations§
Source§impl Color
impl Color
Sourcepub const fn srgb(r: u8, g: u8, b: u8, a: u8) -> Self
pub const fn srgb(r: u8, g: u8, b: u8, a: u8) -> Self
Construct an sRGB-origin color (cmyk is None).
Sourcepub const fn cmyk(c: f32, m: f32, y: f32, k: f32, r: u8, g: u8, b: u8) -> Self
pub const fn cmyk(c: f32, m: f32, y: f32, k: f32, r: u8, g: u8, b: u8) -> Self
Construct a CMYK-origin opaque color from the original channels plus the
already-converted sRGB triple. c/m/y/k are percentages
(0.0..=100.0); the converted r/g/b are supplied by the caller so
the deterministic conversion lives in exactly one place
(zenith_core::cmyk_to_srgb). Alpha is always 255.