Skip to main content

DeviceColor

Struct DeviceColor 

Source
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

Source

pub fn from_gray(gray: f64) -> Self

Source

pub fn from_rgb(r: f64, g: f64, b: f64) -> Self

Source

pub fn from_cmyk(c: f64, m: f64, y: f64, k: f64) -> Self

Source

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.

Source

pub fn from_hsb(h: f64, s: f64, b: f64) -> Self

Source

pub fn to_gray(&self) -> f64

Convert to gray using NTSC luma.

Source

pub fn to_cmyk(&self) -> (f64, f64, f64, f64)

Convert to CMYK (uses native CMYK if available for lossless roundtrip).

Source

pub fn to_hsb(&self) -> (f64, f64, f64)

Convert to HSB.

Source

pub fn black() -> Self

Black (default color).

Source

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].

Source

pub fn from_cie_abc(a: f64, b: f64, c: f64, params: &CieAbcParams) -> Self

Convert CIEBasedABC color to sRGB.

Source

pub fn from_cie_a(a: f64, params: &CieAParams) -> Self

Convert CIEBasedA color to sRGB.

Source

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.

Source

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

Source§

fn clone(&self) -> DeviceColor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeviceColor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DeviceColor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.