Myndex / SAPC-APCA

APCA (Accessible Perceptual Contrast Algorithm) is a new method for predicting contrast for use in emerging web standards (WCAG 3) for determining readability contrast. APCA is derived form the SAPC (S-LUV Advanced Predictive Color) which is an accessibility-oriented color appearance model designed for self-illuminated displays.
https://git.apcacontrast.com/documentation/APCAeasyIntro
Other
443 stars 14 forks source link

Testing APCAonly.98e_d12e.js results do not match #14

Closed NateBaldwinDesign closed 3 years ago

NateBaldwinDesign commented 3 years ago

Hi @Myndex,

I'm testing a local implementation of APCA using APCAonly.98e_d12e.js. I have a test suite with the four test cases you have illustrated here: https://github.com/Myndex/SAPC-APCA/tree/master/JS#testing-your-implementation

However, my results do not match the expected results you've posted. I have tried transposing colors (assuming perhaps I had erroneously placed the text/background colors in the incorrect order). I am wondering if the test cases are incorrect, or if there's something I am missing?

Example of test case running locally:

test('should provide APCA contrast for first test case', function() {
  let contrastValue = APCAcontrast(0xfff, 0x888);

  expect(contrastValue).toBe(66.89346308821438);
});

Result of test:

 Expected: 66.89346308821438
 Received: 11.399627561736908
NateBaldwinDesign commented 3 years ago

Figured this out -- the test needs to be run with full hexidecimal values:

0xffffff

rather than

0xfff
Myndex commented 3 years ago

Egads, really?

DOH edit, see below, APCAonly is stripped down and does not have any special parsing...

ALSO, I discuss the most latest constants in the following issue thread here:

https://github.com/Myndex/SAPC-APCA/issues/12

Which is also on the live demo sites:

Simple Interface: https://www.myndex.com/APCA/

Research Mode: https://www.myndex.com/SAPC/

Myndex commented 3 years ago

Just looked again, the current APCAonly does not have the input value parsing module that handles that that kind of thing, as the APCAonly JS is the most stripped down, without a number of other color related functions.

Thank you for bringing this to my attention... Now that some other code has stabilized I should bring it over to GitHub.

For reference, the file https://www.myndex.com/APCA/JS/DEV98G_SAPCsRGB.js includes color value input parsing and other features, as well as the latest code and constants.

Thank you!

Andy