Module:Color contrast: Difference between revisions

fix
m>Frietjes
(fix)
m>Frietjes
(fix)
Line 122: Line 122:
end
end


local function colors2ratio(c)
function p._ratio(args)
local v1 = color2lum(c[1])
local v1 = color2lum(c[1])
local v2 = color2lum(c[2])
local v2 = color2lum(c[2])
Line 128: Line 128:
return (v2 + 0.05)/(v1 + 0.05)
return (v2 + 0.05)/(v1 + 0.05)
else
else
return ''
return args['error'] or '?'
end
end
end
end
Line 138: Line 138:
function p.ratio(frame)
function p.ratio(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
local args = frame.args[1] and frame.args or frame:getParent().args
local r = colors2ratio(args)
return p._ratio(args)
if (r ~= '') then
return r
else
return frame.args['error'] or frame:getParent().args['error'] or '?'
end
end
end
   
   
return p
return p
Anonymous user