APCA npm Package
One result of my last few years of research into human visual perepotion has been the creation of the Advanced Perceptual Contrast Algorithm for WCAG_3 (Silver).
While research continues, the public beta APCA npm package is now available: apca-w3
npm i apca-w3
And the API is trivially simple: send it two colors, it returns a signed INT of the Lc value (lightness contrast).
Lc = APCAcontrast( sRGBtoY( textColor ), sRGBtoY( backgroundColor ) );
Color sent to the required parsing function
sRGBtoY() can be a 3 or 6 character hex string
a3b3d4 (hash # is optional but not required), a named CSS color (such as
rgb(99,122,14), or as a number
15213412. Text color first, background color second — do not swap colors, as use case affects results. light text on a dark background returns a negative value.
For questions and comments please visit the main APCA repo discussion area.