Copyright (c) Jesse David Martin (@motleydev) | MIT license Formulas stolen directly from @snookca / verified against the WCAG2 Spec https://snook.ca/technical/colour_contrast/colour.html
Kind: global constant
- colorCheck
- .hexToRgb(hex) ⇒
object
- .colorDifference(hex, hex) ⇒
boolean
- .colorBrightnessDifference(hex, hex) ⇒
boolean
- .colorGetLuminance(hex) ⇒
number
- .colorContrast(hex, hex) ⇒
number
- .colorCompliance(hex, hex) ⇒
boolean
- .aa(hex, hex) ⇒
boolean
- .aa_18(hex, hex) ⇒
boolean
- .aaa(hex, hex) ⇒
boolean
- .aaa_18(hex, hex) ⇒
boolean
- .hexToRgb(hex) ⇒
Checks if a hex string or object was given and returns the rgb color values of the former. To keep a tiny library, it's the user's responsibility to provide valid hex/rgbObj values.
Kind: static method of colorCheck
Returns: object
- returns an object of shape {r, g, b}
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
Checks if the two colors have significant color difference
Kind: static method of colorCheck
Returns: boolean
- gives a numeric value must be 500 or greater
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
hex | string | object |
color string or object of shape {r, g, b} |
returns a boolean value if there is enough brightness difference
Kind: static method of colorCheck
Returns: boolean
- gives a numeric value must be over 125
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
hex | string | object |
color string or object of shape {r, g, b} |
returns a numeric value of the total luminance
Kind: static method of colorCheck
Returns: number
- gives a numeric value
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
returns a numeric value for the color contrast
Kind: static method of colorCheck
Returns: number
- gives a numeric value
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
hex | string | object |
color string or object of shape {r, g, b} |
returns a boolean if the values are both color compliant and contrast compliant
Kind: static method of colorCheck
Returns: boolean
- gives a boolean response.
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
hex | string | object |
color string or object of shape {r, g, b} |
returns a boolean if the value is acceptable for AA standards for legibility of size 14pt font.
Kind: static method of colorCheck
Returns: boolean
- gives a boolean response.
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
hex | string | object |
color string or object of shape {r, g, b} |
returns a boolean if the value is acceptable for AA standards for legibility of size 18pt font.
Kind: static method of colorCheck
Returns: boolean
- gives a boolean response.
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
hex | string | object |
color string or object of shape {r, g, b} |
returns a boolean if the value is acceptable for AAA standards for legibility of size 14pt font. It's ok, this is very hard to achieve.
Kind: static method of colorCheck
Returns: boolean
- gives a boolean response.
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
hex | string | object |
color string or object of shape {r, g, b} |
returns a boolean if the value is acceptable for AAA standards for legibility of size 18pt font. It's ok, this is hard to achieve.
Kind: static method of colorCheck
Returns: boolean
- gives a boolean response.
Param | Type | Description |
---|---|---|
hex | string | object |
color string or object of shape {r, g, b} |
hex | string | object |
color string or object of shape {r, g, b} |