But isn’t there something more fundamentally wrong with this measure, with the criteria outlined by Sannyasin:
> * Small text should have a contrast ratio of at least 4.5:1 against its > background. A ratio of 7:1 is preferred. > * Large text (at 14 pt bold/18 pt regular and up) should have a contrast > ratio of at least 3:1 against its background. If you’re comparing something with black, it’s very easy to get a high luminance ratio but text will still be unreadable. Try setting a field’s forecolor to 5,5,5 and the backcolor to 45,45,45. The luminance ratio is 8.27, but you can’t read the text at all. — Peter Peter M. Brigham pmb...@gmail.com > On Oct 6, 2016, at 5:34 PM, hh <h...@hyperhh.de> wrote: > >> Jacqueline L.G. wrote: >> Does this work well enough?: >> >> function luminanceRatio c1,c2 -- pass two RGB triplets >> put calcLuminance(c1) into tL1 >> put calcLuminance(c2) into tL2 >> return max(tL1,tL2) / min(tL1,tL2) >> end luminanceRatio >> >> function calcLuminance pRGB >> -- wikipedia: Y = 0.2126 R + 0.7152 G + 0.0722 B >> put item 1 of pRGB * 0.2126 into tR >> put item 2 of pRGB * 0.7152 into tG >> put item 3 of pRGB * 0.0722 into tB >> return sum(tR,tG,tB) >> # if sum(tR,tG,tB) > 125 then return "black" >> # else return "white" >> end calcLuminance > > In case black is also an option as color then the following > ratio, known as contrast ratio, avoids dividing by zero: > > function contrastRatio c1,c2 -- pass two RGB triplets > put calcLuminance(c1) into tL1 > put calcLuminance(c2) into tL2 > return (0.05 + max(tL1,tL2)) / (0.05 + min(tL1,tL2)) > end contrastRatio > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode