Skip to content

Latest commit

 

History

History
155 lines (111 loc) · 6.57 KB

api.md

File metadata and controls

155 lines (111 loc) · 6.57 KB

colorCheck

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

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}

colorCheck.colorDifference(hex, hex) ⇒ boolean

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}

colorCheck.colorBrightnessDifference(hex, hex) ⇒ boolean

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}

colorCheck.colorGetLuminance(hex) ⇒ number

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}

colorCheck.colorContrast(hex, hex) ⇒ number

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}

colorCheck.colorCompliance(hex, hex) ⇒ boolean

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}

colorCheck.aa(hex, hex) ⇒ boolean

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}

colorCheck.aa_18(hex, hex) ⇒ boolean

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}

colorCheck.aaa(hex, hex) ⇒ boolean

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}

colorCheck.aaa_18(hex, hex) ⇒ boolean

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}