OT: Type on Background - Contrast Ratios

Sannyasin Brahmanathaswami brahma at hindu.org
Thu Oct 6 16:23:37 EDT 2016


Awesome! thanks… will add immediately to my UX design toolbox… 

Svasti Astu, Be Well 
Brahmanathaswami

www.himalayanacademy.com

 

On 10/6/16, 9:21 AM, "use-livecode on behalf of J. Landman Gay" <use-livecode-bounces at lists.runrev.com on behalf of jacque at hyperactivesw.com> 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
    
    



More information about the use-livecode mailing list