Skip to content

Function: getLuminance()

ts
function getLuminance(hex): number;

Returns the relative luminance (0–1) of a hex color per WCAG 2.x.

Parameters

ParameterType
hexstring

Returns

number

Example

ts
getLuminance('#ffffff') // => 1
getLuminance('#000000') // => 0

Since

1.0.0

Released under the MIT License.