Module: color

color

color module
Source:

Classes

Color

Methods

<inner> calculateContrastRatio(fgColor, bgColor) → {number}

Calculate the contrast ratio between the two given colors. Returns the ratio to 1, for example for two two colors with a contrast ratio of 21:1, this function will return 21.
Parameters:
Name Type Description
fgColor Color the foreground color.
bgColor Color the background color.
Source:
Returns:
Type
number

<inner> flattenColors(fgColor, bgColor) → {Color}

Combine the two given colors according to alpha blending.
Parameters:
Name Type Description
fgColor Color the foreground color.
bgColor Color the background color.
Source:
Returns:
Type
Color

<inner> suggestColors(bgColor, fgColor, desiredContrastRatios) → {Object.<string, string>}

Suggests alternative color suggestions to meet a given contrast ratio.
Parameters:
Name Type Description
bgColor Color the background color.
fgColor Color the foreground color.
desiredContrastRatios Object.<string, number> A map of label to desired contrast ratio.
Source:
Returns:
Type
Object.<string, string>