whocanuse icon indicating copy to clipboard operation
whocanuse copied to clipboard

Add SAPC support

Open CoreyGinnivan opened this issue 4 years ago • 3 comments

https://github.com/Myndex/SAPC/tree/master/JS

CoreyGinnivan avatar Apr 15 '20 05:04 CoreyGinnivan

I expect to have an npm package soon. Also just as an FYI we're calling the basic free algorithm "APCA" now... SAPC is the full appearance model...

Myndex avatar Nov 29 '21 05:11 Myndex

APCA npm Package

The APCA npm package is now available: apca-w3

Install:

 npm i apca-w3

Usage:

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 ) );

Implementation notes:

Color sent to the required parsing function sRGBtoY() can be a 3 or 6 character hex string #fff or a3b3d4 (hash # is optional but not required), a named CSS color (such as aquamarine), as rgb(99,122,14), or as a number 0x123456 or 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.

Thank you!

Andy

Myndex avatar Dec 05 '21 02:12 Myndex

Hey @CoreyGinnivan I'm not sure if you are aware but we released Bridge-PCA which is backwards compatible with the old WCAG 2, but using APCA technology — if you pass Bridge-PCA you automatically pass WCAG 2.

Also available as an npm package:

 npm i bridge-pca

Thank you!

Andy

Myndex avatar Jan 09 '22 19:01 Myndex