Color.Rec2020
(Color v0.11.0)
Copy Markdown
ITU-R BT.2020 / Rec. 2020 color space, using the Rec. 2020 wide-gamut primaries (D65 reference white) and the BT.2020 SDR opto-electronic transfer function at 12-bit precision.
Rec. 2020 is the wide-gamut color space standardised for UHDTV and is the basis for HDR signalling in BT.2100 (with PQ or HLG encoding). Its primaries enclose a substantially larger portion of the visible spectral locus than sRGB or P3.
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 Rec. 2020.
Converts a Rec. 2020 color to a CIE XYZ color.
Types
Functions
@spec from_xyz(Color.XYZ.t()) :: {:ok, t()}
Converts a CIE XYZ color (assumed D65/2°) to Rec. 2020.
Arguments
xyzis aColor.XYZstruct.
Returns
- A
Color.Rec2020struct.
Examples
iex> xyz = %Color.XYZ{x: 0.95047, y: 1.0, z: 1.08883, illuminant: :D65, observer_angle: 2}
iex> {:ok, rec} = Color.Rec2020.from_xyz(xyz)
iex> {Float.round(rec.r, 3), Float.round(rec.g, 3), Float.round(rec.b, 3)}
{1.0, 1.0, 1.0}
@spec to_xyz(t()) :: {:ok, Color.XYZ.t()}
Converts a Rec. 2020 color to a CIE XYZ color.
Arguments
rec2020is aColor.Rec2020struct with unit-range channels.
Returns
- A
Color.XYZstruct tagged with D65/2°,Y ∈ [0, 1].
Examples
iex> {:ok, xyz} = Color.Rec2020.to_xyz(%Color.Rec2020{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}