wcag-contrast

evaluate the wcag color contrast score for two colors

npm install wcag-contrast
4 downloads in the last month

Build Status

wcag color constrast

WCAG contrast ratio measurement and scoring.

api

luminance(a, b)

Return contrast as a numeric ratio given two relative luminances

rgb(a, b)

Return contrast as a numeric ratio given two rgb triplets

score(contrast)

Return score in ('AAA', 'AA', '') given contrast ratio as number.

example

var contrast = require('wcag-contrast');
var ratio = contrast.rgb([0, 0, 0], [255, 255, 255]); // is 21
var score = contrast.score(ratio); // is 'AAA'
npm loves you