Module:Color contrast: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
No edit summary
No edit summary
Line 69: Line 69:
-- convert from hsl
-- convert from hsl
if mw.ustring.match(c,'^hsl%([%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*%%[%s]*,[%s]*[0-9][0-9]*%%[%s]*%)$') then
if mw.ustring.match(c,'^hsl%([%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*%%[%s]*,[%s]*[0-9][0-9]*%%[%s]*%)$') then
local h = mw.ustring.match(c,'^hsl%[%s]*([0-9][0-9]*)[%s]*,[%s]*[0-9][0-9]*%%[%s]*,[%s]*[0-9][0-9]*%%[%s]*%$')
local h = mw.ustring.match(c,'^hsl%([%s]*([0-9][0-9]*)[%s]*,[%s]*[0-9][0-9]*%%[%s]*,[%s]*[0-9][0-9]*%%[%s]*%)$')
local s = mw.ustring.match(c,'^hsl%[%s]*[0-9][0-9]*[%s]*,[%s]*([0-9][0-9]*)%%[%s]*,[%s]*[0-9][0-9]*%%[%s]*%$')
local s = mw.ustring.match(c,'^hsl%([%s]*[0-9][0-9]*[%s]*,[%s]*([0-9][0-9]*)%%[%s]*,[%s]*[0-9][0-9]*%%[%s]*%)$')
local l = mw.ustring.match(c,'^hsl%[%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*%%[%s]*,[%s]*([0-9][0-9]*)%%[%s]*%$')
local l = mw.ustring.match(c,'^hsl%([%s]*[0-9][0-9]*[%s]*,[%s]*[0-9][0-9]*%%[%s]*,[%s]*([0-9][0-9]*)%%[%s]*%)$')
return hsl2rgb(tonumber(h), tonumber(s)/100, tonumber(l)/100)
return hsl2rgb(tonumber(h), tonumber(s)/100, tonumber(l)/100)
end
end