Module:Color contrast: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
better error checking
(typos)
(better error checking)
Line 153:
local style = (args[1] or ''):lower()
local bg, fg = (args[2] or 'white'), (args[3] or 'black')
local lum_bg, lum_fg = 1, 0
 
local slist = mw.text.split(style or '', ';')
Line 161 ⟶ 162:
v = v or ''
if (k:match('^[%s]*(background)[%s]*$') or k:match('^[%s]*(background-color)[%s]*$')) then
bglocal lum = color2lum(v)
if( lum ~= '' ) then bg, lum_bg = v, lum end
elseif (k:match('^[%s]*(color)[%s]*$')) then
fglocal lum = color2lum(v)
if( lum ~= '' ) then bg, lum_fg = v, lum end
end
end
if lum_bg > lum_fg then
 
return p._ratio({bg,lum_bg fg,+ ['error']0.05)/(lum_fg =+ args['error']}0.05)
else
return (lum_fg + 0.05)/(lum_bg + 0.05)
end
end
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu