Referencia contrast()

contrast()

Checks the contrast between two colors. This method returns a boolean value to indicate if the two color has enough contrast. true means that the colors has enough contrast to be used as background color and body text color. false means there is not enough contrast.

A second argument can be passed to the method, options , which defines the algorithm to be used. The algorithms currently supported are WCAG 2.1 ('WCAG21') or APCA ('APCA'). The default is WCAG 2.1. If a value of 'all' is passed to the options argument, an object containing more details is returned. The details object will include the calculated contrast value of the colors and different passing criteria.

For more details about color contrast, you can check out this page from color.js, and the WebAIM color contrast checker.

Ejemplos

Sintaxis

contrast(other)
contrast(other)
contrast(other)
contrast(other)
contrast(other)

Parámetros

other
Color:

Returns

boolean|object:
Notice any errors or typos? Please let us know. Please feel free to edit src/color/p5.Color.js and open a pull request!

Referencias Relacionadas