Template talk:Color contrast ratio

(Redirected from Template talk:Color contrast ratio/sandbox)
Latest comment: 11 years ago by AlanM1 in topic Wrong ratio?

Wrong ratio?

edit

I noticed some values do not match with the ones provided by the Colour Contrast Check:

Text Color Background color Sample Code Contrast ratio
Template Tool
#BADFEE black   Sample   {{Color contrast ratio|#BaDFeE|BlAcK}} 0.067215591908977 14.88
red black   Sample   {{Color contrast ratio|red|black}} 0.19040365575019 5.25
#FFFF00 #00FFFF   Sample   {{Color contrast ratio|#FFFF00|#00FFFF}} 0.85641235426468 1.17

Helder 12:31, 6 March 2013 (UTC)Reply

Note the values provided are the reciprocal of those given by the other tool. That's because the other tool reverses the order of the parameters if the foreground color is lighter than the background color, while this template was designed (and is documented) to provide the correct ratio (less than 1). This is to provide more flexibility for the user, who may want to filter dark-on-light contrasts differently than light-on-dark for hardware or environmental differences. In practice, it just means that you have to check that the value is inside a range instead of being less than a specific value (e.g. 0.25<=x<=4.0 instead of x<=4.0). —[AlanM1(talk)]— 17:59, 14 March 2013 (UTC)Reply