Content deleted Content added
Jackmcbarn (talk | contribs) simplify sRGB |
Jackmcbarn (talk | contribs) add error checking to color2lum |
||
Line 15:
end
end
local function color2lum(
local
if not c then
error('Invalid hex color ' .. origc, 2)
end
local cs = mw.text.split(c, '')
local R, G, B
if
R = sRGB( tonumber(cs[1] .. cs[2], 16)/255 )
G = sRGB( tonumber(cs[3] .. cs[4], 16)/255 )
B = sRGB( tonumber(cs[5] .. cs[6], 16)/255 )
elseif
R = sRGB( tonumber(
G = sRGB( tonumber(
B = sRGB( tonumber(
else
error('
end
return 0.2126 * R + 0.7152 * G + 0.0722 * B
|