Module:Color contrast: Difference between revisions
fix
m>Frietjes (refactor to allow this to be called from another module) |
m>Frietjes (fix) |
||
Line 122: | Line 122: | ||
end | end | ||
local function colors2ratio( | local function colors2ratio(c) | ||
local v1 = color2lum( | local v1 = color2lum(c[1]) | ||
local v2 = color2lum( | local v2 = color2lum(c[2]) | ||
if (type(v1) == 'number' and type(v2) == 'number') then | if (type(v1) == 'number' and type(v2) == 'number') then | ||
return (v2 + 0.05)/(v1 + 0.05) | return (v2 + 0.05)/(v1 + 0.05) | ||
Line 137: | Line 137: | ||
function p.ratio(frame) | function p.ratio(frame) | ||
local | local args = frame.args[1] and frame.args or frame:getParent().args | ||
local r = colors2ratio(args) | |||
if (r ~= '') then | if (r ~= '') then | ||
return r | return r |