w3c / silver

Accessibility Guidelines "Silver"
https://w3c.github.io/silver/
Other
199 stars 44 forks source link

APCA constants - consistent naming #645

Open svgeesus opened 2 years ago

svgeesus commented 2 years ago

(I would raise an issue on the constants in WCAG 3, but they haven't been added yet until https://github.com/w3c/silver/pull/570 is merged)

The problem

The Current APCA Constants ( 0.0.98G - W3 last changed Feb 15, 2021 ) lists constants, but gives no equations.

The APCA Base Math (sRGB) lists constants and equations, but the names used are not the same and the set of constants is not exactly equivalent.

When implementing, I mainly used the value of the constants to check equivalence (which kind of defeats the point of named constants) but clearly this fails if two constants have the same value and the mapping is not immediately obvious.

Correspondences

The correspondences seem to be:

Constant Value Base Math
exponents
mainTRC2.4no name
normBG0.56no name
normTXT0.57no name
revTXT0.62no name
revBG0.65no name
colorSpace
sRco0.2126729no name
sGco0.7151522no name
sBco0.0721750no name
clamp
blkThrs0.022Bthresh
blkClmp1.414Bexp
loClip0.1Pout
deltaYmin0.0005Pin
scalers
scaleBoW1.14Rscale
loBoWoffset0.027Woffset
scaleWoB1.14Rscale
loWoBoffset0.027Woffset

Suggested fixes

  1. Give the un-named constants names
  2. Change Bexp to Bclmp, or otherwise make the correspondence obvious
  3. Either change Pout to something like Cliplow, or change loClip to Pout
  4. Either change Pin to something like deltaYmin, or change deltaYmin to Pin
  5. Either decide that the WoB and BoW scalers and offsets might be different, and thus mint new names for use in base math (like BoWscale, WoBscale, BoWoffset, WoBoffset )or decide that they will be the same going forward and mint just two new names for the constants, like scale and offset.

Also

In addition, please be aware that the chosen 5-digit chromaticity values for D65 differ slightly from the 4-digit ones used in CSS Color 4 (the latter being changed several times, although we finally went for the 4-digit ones throughout for consistency with the defining color space specifications) and also that the matrix coefficients for RGB to Y also differ from both CSS and the sRGB specification. The CSS ones were calculated from first principles and agree with the sRGB standard ones when rounded to 8 significant figures.

Myndex commented 2 years ago

If I understand it, just the consistency between the code and the LaTeX svg? I probably should just lose the LaTeX as it's probably more confusing than helpful.

The constants in the LaTeX are intentionally different, as it originated at a time when the code was changing rapidly including variable names etc. The LaTeX does not really serve a purpose anymore as I think of it. It would probably be best at this point to create a pseudocode, or just show the basic JS.

Regarding PR #213 or #570 (or the #568 which I closed to make #570, trying to figure out why they are not being merged, and not getting any answers) Most recently I was told that that entire page would be deleted so that it was no longer something linked to, which is probably ideal.

Regarding the D65 and the chromaticity coefficients: I am using the BruceLindbloom ones also intentionally, as there was some experimentation in the past regarding the coefficients relating to certain impairments, and I wanted it to be easily recognizable that they were different.

But as discussed in other threads, those will change as I align things to the CSS 4 values for all of the standard "CIE/IEC" stuff.

svgeesus commented 2 years ago

The constants in the LaTeX are intentionally different, as it originated at a time when the code was changing rapidly including variable names etc. The LaTeX does not really serve a purpose anymore as I think of it. It would probably be best at this point to create a pseudocode, or just show the basic JS.

As long as the equations are clearly documented such that they can be independently implemented.

Myndex commented 2 years ago

I am working on organizing and cleaning up documentation, and streamlining it to improve access and understanding.