pub struct DeviceColor {
pub r: f64,
pub g: f64,
pub b: f64,
pub native_cmyk: Option<(f64, f64, f64, f64)>,
pub process_cmyk: Option<(f64, f64, f64, f64)>,
}Expand description
Device color in RGB (internal representation) with optional native CMYK.
Fields§
§r: f64§g: f64§b: f64§native_cmyk: Option<(f64, f64, f64, f64)>Native CMYK components for lossless roundtrip when color space is CMYK. For DeviceN/Separation paints this is the full alt-CMYK tint transform (process + spot contributions combined).
process_cmyk: Option<(f64, f64, f64, f64)>Process-colorant-only CMYK contribution. Populated by DeviceN/Separation
paints so the overprint tracker can record only what actually lands on
process plates (C/M/Y/K), leaving any spot colorant’s alt-CMYK out of
the process buffer. None means “use native_cmyk as the process
contribution” (pure DeviceCMYK / DeviceGray / DeviceRGB).
Implementations§
Source§impl DeviceColor
impl DeviceColor
pub fn from_gray(gray: f64) -> Self
pub fn from_rgb(r: f64, g: f64, b: f64) -> Self
pub fn from_cmyk(c: f64, m: f64, y: f64, k: f64) -> Self
Sourcepub fn from_cmyk_icc(c: f64, m: f64, y: f64, k: f64, icc: &mut IccCache) -> Self
pub fn from_cmyk_icc(c: f64, m: f64, y: f64, k: f64, icc: &mut IccCache) -> Self
Create from CMYK, converting through ICC profile if available. Falls back to PLRM formula when ICC is unavailable.
pub fn from_hsb(h: f64, s: f64, b: f64) -> Self
Sourcepub fn to_cmyk(&self) -> (f64, f64, f64, f64)
pub fn to_cmyk(&self) -> (f64, f64, f64, f64)
Convert to CMYK (uses native CMYK if available for lossless roundtrip).
Sourcepub fn from_lab(l_star: f64, a_star: f64, b_star: f64, range: &[f64; 4]) -> Self
pub fn from_lab(l_star: f64, a_star: f64, b_star: f64, range: &[f64; 4]) -> Self
Convert CIE L*a*b* to sRGB.
PDF Lab color spaces specify a white point, but Lab is perceptually uniform — the same (L*, a*, b*) coordinates represent the same perceived color regardless of the declared white point. We convert directly through D65 (the sRGB reference illuminant), which makes the specified white point irrelevant and avoids Bradford adaptation errors for extreme/non-physical white points.
range is the a*/b* clamp range: [a_min, a_max, b_min, b_max].
Sourcepub fn from_cie_abc(a: f64, b: f64, c: f64, params: &CieAbcParams) -> Self
pub fn from_cie_abc(a: f64, b: f64, c: f64, params: &CieAbcParams) -> Self
Convert CIEBasedABC color to sRGB.
Sourcepub fn from_cie_a(a: f64, params: &CieAParams) -> Self
pub fn from_cie_a(a: f64, params: &CieAParams) -> Self
Convert CIEBasedA color to sRGB.
Sourcepub fn from_cie_def(d: f64, e: f64, f: f64, params: &CieDefParams) -> Self
pub fn from_cie_def(d: f64, e: f64, f: f64, params: &CieDefParams) -> Self
Convert CIEBasedDEF color to sRGB via pre-converted trilinear interpolation table.
Sourcepub fn from_cie_defg(
d: f64,
e: f64,
f: f64,
g: f64,
params: &CieDefgParams,
) -> Self
pub fn from_cie_defg( d: f64, e: f64, f: f64, g: f64, params: &CieDefgParams, ) -> Self
Convert CIEBasedDEFG color to sRGB via pre-converted nearest-neighbor 4D table.
Trait Implementations§
Source§impl Clone for DeviceColor
impl Clone for DeviceColor
Source§fn clone(&self) -> DeviceColor
fn clone(&self) -> DeviceColor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more