Color.CMYK (Color v0.4.0)

Copy Markdown

Device CMYK color space. This is the simple "subtractive from sRGB" device CMYK — it does NOT use an ICC profile, so it is not suitable for color-accurate print workflows. For that, pass the sRGB (or AdobeRGB) struct through a real CMS.

All channels are unit floats in [0, 1].

Summary

Types

t()

A simple subtractive CMYK colour. Each of c, m, y, k is a unit float in [0.0, 1.0]. No ICC profile is implied — this is device-independent CMYK suitable for device-cmyk() interchange, not for press output.

Functions

Converts an sRGB color to CMYK.

Converts a CIE XYZ color to CMYK via sRGB.

Converts a CMYK color to sRGB.

Converts a CMYK color to CIE XYZ via sRGB.

Types

t()

@type t() :: %Color.CMYK{
  alpha: Color.Types.alpha(),
  c: float() | nil,
  k: float() | nil,
  m: float() | nil,
  y: float() | nil
}

A simple subtractive CMYK colour. Each of c, m, y, k is a unit float in [0.0, 1.0]. No ICC profile is implied — this is device-independent CMYK suitable for device-cmyk() interchange, not for press output.

Functions

from_srgb(srgb)

Converts an sRGB color to CMYK.

Arguments

Returns

Examples

iex> {:ok, cmyk} = Color.CMYK.from_srgb(%Color.SRGB{r: 0.0, g: 0.0, b: 1.0})
iex> {cmyk.c, cmyk.m, cmyk.y, cmyk.k}
{1.0, 1.0, 0.0, 0.0}

from_xyz(xyz)

Converts a CIE XYZ color to CMYK via sRGB.

to_srgb(cmyk)

Converts a CMYK color to sRGB.

Arguments

Returns

Examples

iex> {:ok, srgb} = Color.CMYK.to_srgb(%Color.CMYK{c: 0.0, m: 0.0, y: 0.0, k: 0.0})
iex> {srgb.r, srgb.g, srgb.b}
{1.0, 1.0, 1.0}

iex> {:ok, srgb} = Color.CMYK.to_srgb(%Color.CMYK{c: 1.0, m: 1.0, y: 0.0, k: 0.0})
iex> {srgb.r, srgb.g, srgb.b}
{0.0, 0.0, 1.0}

to_xyz(cmyk)

Converts a CMYK color to CIE XYZ via sRGB.