Module: rec2020

ITU-R Rec. 2020 (Rec. 2020) color space conversions and utilities. Rec. 2020 is an ultra-wide gamut RGB color space used for UHDTV (4K/8K) and HDR content. It encompasses 75.8% of the CIE 1931 color space, significantly larger than sRGB (35.9%) and Display P3 (53.6%).
Source:
See:

Methods

(static) benefitsFromRec2020(srgbColor) → {boolean}

Check if an sRGB color would benefit from Rec. 2020's wider gamut
Parameters:
Name Type Description
srgbColor SrgbColor sRGB color to check
Source:
Returns:
True if converting to Rec. 2020 provides a wider gamut representation
Type
boolean

(static) formatRec2020ForCSS(rec2020Color, precisionopt) → {string}

Format a Rec. 2020 color for CSS Color Module Level 4
Parameters:
Name Type Attributes Default Description
rec2020Color Rec2020Color Rec. 2020 color
precision number <optional>
4 Decimal precision
Source:
Returns:
CSS color() function string
Type
string
Example
formatRec2020ForCSS({ r: 0.627, g: 0.069, b: 0.016 })
// Returns: "color(rec2020 0.627 0.069 0.016)"

(static) getRec2020GamutRatio(compareSpaceopt) → {number}

Get the gamut volume of Rec. 2020 relative to other spaces
Parameters:
Name Type Attributes Default Description
compareSpace string <optional>
'srgb' Space to compare against
Source:
Returns:
Ratio of gamut volumes
Type
number

(static) isRec2020InSrgbGamut(rec2020Color) → {boolean}

Check if a Rec. 2020 color is within sRGB gamut
Parameters:
Name Type Description
rec2020Color Rec2020Color Rec. 2020 color to check
Source:
Returns:
True if the color can be represented in sRGB
Type
boolean

(static) linearRec2020ToRec2020(linearRec2020Color) → {Rec2020Color}

Convert linear Rec. 2020 to Rec. 2020 with gamma correction
Parameters:
Name Type Description
linearRec2020Color LinearRec2020Color Linear Rec. 2020 color
Source:
Returns:
Rec. 2020 color with gamma correction
Type
Rec2020Color

(static) linearRec2020ToXyz(linearRec2020Color) → {Object}

Convert linear Rec. 2020 to XYZ (D65)
Parameters:
Name Type Description
linearRec2020Color LinearRec2020Color Linear Rec. 2020 color
Source:
Returns:
XYZ color
Type
Object

(static) parseRec2020FromCSS(cssString) → {Rec2020Color|null}

Parse a CSS Color Module Level 4 rec2020 color
Parameters:
Name Type Description
cssString string CSS color() function string
Source:
Returns:
Rec. 2020 color or null if invalid
Type
Rec2020Color | null
Example
parseRec2020FromCSS("color(rec2020 0.627 0.069 0.016)")
// Returns: { r: 0.627, g: 0.069, b: 0.016 }

(static) rec2020ToLinearRec2020(rec2020Color) → {LinearRec2020Color}

Convert Rec. 2020 to linear Rec. 2020
Parameters:
Name Type Description
rec2020Color Rec2020Color Rec. 2020 color with gamma correction
Source:
Returns:
Linear Rec. 2020 color
Type
LinearRec2020Color

(static) rec2020ToSrgb(rec2020Color) → {SrgbColor}

Convert Rec. 2020 to sRGB Note: Rec. 2020 has a much wider gamut than sRGB, so colors will often be clipped
Parameters:
Name Type Description
rec2020Color Rec2020Color Rec. 2020 color
Source:
Returns:
sRGB color (likely clipped if out of gamut)
Type
SrgbColor

(static) srgbToRec2020(srgbColor) → {Rec2020Color}

Convert sRGB to Rec. 2020
Parameters:
Name Type Description
srgbColor SrgbColor sRGB color
Source:
Returns:
Rec. 2020 color
Type
Rec2020Color
Example
// Convert pure red from sRGB to Rec. 2020
const rec2020Red = srgbToRec2020({ r: 1, g: 0, b: 0 });

(static) xyzToLinearRec2020(xyzColor) → {LinearRec2020Color}

Convert XYZ (D65) to linear Rec. 2020
Parameters:
Name Type Description
xyzColor Object XYZ color
Source:
Returns:
Linear Rec. 2020 color
Type
LinearRec2020Color

Type Definitions

LinearRec2020Color

Type:
  • Object
Source:

Rec2020Color

Type:
  • Object
Source: