Color.AppleRGB (Color v0.11.0)

Copy Markdown

Apple RGB color space, using the Lindbloom Apple RGB working space (primaries from the original Apple 13" RGB display, D65 reference white) and simple gamma companding with γ = 1.8.

Apple RGB is a legacy working space from classic Mac OS — it approximates the gamut of Apple's early colour displays. Most modern work should use sRGB, Display P3, or Rec. 2020 instead; Color.AppleRGB is primarily useful for reading or writing assets produced with legacy Mac software.

Channels r, g and b are unit floats in the nominal range [0, 1].

Summary

Functions

Converts a CIE XYZ color (assumed D65/2°) to Apple RGB.

Converts an Apple RGB color to a CIE XYZ color.

Types

t()

@type t() :: %Color.AppleRGB{
  alpha: number() | nil,
  b: number() | nil,
  g: number() | nil,
  r: number() | nil
}

Functions

from_xyz(xyz)

@spec from_xyz(Color.XYZ.t()) :: {:ok, t()}

Converts a CIE XYZ color (assumed D65/2°) to Apple RGB.

Arguments

Returns

Examples

iex> xyz = %Color.XYZ{x: 0.95047, y: 1.0, z: 1.08883, illuminant: :D65, observer_angle: 2}
iex> {:ok, apple} = Color.AppleRGB.from_xyz(xyz)
iex> {Float.round(apple.r, 3), Float.round(apple.g, 3), Float.round(apple.b, 3)}
{1.0, 1.0, 1.0}

to_xyz(apple_rgb)

@spec to_xyz(t()) :: {:ok, Color.XYZ.t()}

Converts an Apple RGB color to a CIE XYZ color.

Arguments

Returns

  • A Color.XYZ struct tagged with D65/2°, Y ∈ [0, 1].

Examples

iex> {:ok, xyz} = Color.AppleRGB.to_xyz(%Color.AppleRGB{r: 1.0, g: 1.0, b: 1.0})
iex> {Float.round(xyz.x, 4), Float.round(xyz.y, 4), Float.round(xyz.z, 4)}
{0.9505, 1.0, 1.0888}