ContrastChecker
Collection of functions that check properties of given colors
Static Method Summary
Static Public Methods | ||
public static |
contrastRatio(foreground: string | Array<number, number, number>, background: string | Array<number, number, number>): number Calculate the contrast ratio of given colors |
|
public static |
Check if the contrast ratio of a given color against black is higher than against white. |
|
public static |
ratioToLevel(ratio: number): string Rate a given contrast ratio according to the WCAG 2.0 criteria |
|
public static |
Calculate the relative luminance of a RGB color given as a string or an array of numbers |
Static Public Methods
public static contrastRatio(foreground: string | Array<number, number, number>, background: string | Array<number, number, number>): number source
Calculate the contrast ratio of given colors
public static isLightColor(color: string | Array<number, number, number>): boolean source
Check if the contrast ratio of a given color against black is higher than against white.
Return:
boolean | true if the contrast ratio against white is qual to or less than the ratio against black |
public static ratioToLevel(ratio: number): string source
Rate a given contrast ratio according to the WCAG 2.0 criteria
Params:
Name | Type | Attribute | Description |
ratio | number | Contrast ratio |