Module:Color contrast: Difference between revisions
fix for garbage input
imported>MacFan4000 m (1 revision imported) |
m>Frietjes (fix for garbage input) |
||
Line 126: | Line 126: | ||
local c3 = args[3] or '#000000' | local c3 = args[3] or '#000000' | ||
local v3 = color2lum(c3) | local v3 = color2lum(c3) | ||
local ratio1 = | local ratio1 = -1; | ||
local ratio2 = | local ratio2 = -1; | ||
if (type(v1) == 'number' and type(v2) == 'number') then | if (type(v1) == 'number' and type(v2) == 'number') then | ||
ratio1 = (v2 + 0.05)/(v1 + 0.05) | ratio1 = (v2 + 0.05)/(v1 + 0.05) | ||
Line 136: | Line 136: | ||
ratio2 = (ratio2 < 1) and 1/ratio2 or ratio2 | ratio2 = (ratio2 < 1) and 1/ratio2 or ratio2 | ||
end | end | ||
return (ratio1 + bias > ratio2) and c2 or c3 | return (ratio1 > 0) and (ratio2 > 0) and ((ratio1 + bias > ratio2) and c2 or c3) or '' | ||
end | end | ||