Module:Color contrast: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(add shorthand) |
(refactor to allow this to be called from another module) |
||
Line 120: | Line 120: | ||
-- failure, return blank |
-- failure, return blank |
||
return '' |
return '' |
||
end |
|||
local function colors2ratio(c1,c2) |
|||
local v1 = color2lum(c1) |
|||
local v2 = color2lum(c2) |
|||
⚫ | |||
⚫ | |||
else |
|||
return '' |
|||
end |
|||
end |
end |
||
Line 127: | Line 137: | ||
function p.ratio(frame) |
function p.ratio(frame) |
||
local r = colors2ratio( |
|||
⚫ | |||
frame.args[1] or frame:getParent().args[1], |
|||
⚫ | |||
⚫ | |||
) |
|||
⚫ | |||
if (r ~= '') then |
|||
return r |
|||
else |
else |
||
return frame.args['error'] or frame:getParent().args['error'] or '?' |
return frame.args['error'] or frame:getParent().args['error'] or '?' |