Content deleted Content added
|
|
-- split into rgb
local cs = mw.text.split(c, '')
local R, G, B
if( #cs == 6 ) then
local R = sRGB( (16*tonumber('0x' .. cs[1]) + tonumber('0x' .. cs[2]))/255 )
local G = sRGB( (16*tonumber('0x' .. cs[3]) + tonumber('0x' .. cs[4]))/255 )
local B = sRGB( (16*tonumber('0x' .. cs[5]) + tonumber('0x' .. cs[6]))/255 )
L = 0.2126 * R + 0.7152 * G + 0.0722 * B ▼
return L
elseif ( #cs == 3 ) then
local R = sRGB( (16*tonumber('0x' .. cs[1]) + tonumber('0x' .. cs[1]))/255 )
local G = sRGB( (16*tonumber('0x' .. cs[2]) + tonumber('0x' .. cs[2]))/255 )
local B = sRGB( (16*tonumber('0x' .. cs[3]) + tonumber('0x' .. cs[3]))/255 )
else
error('Invalid hex color ' .. origc, 2) ▼
L = 0.2126 * R + 0.7152 * G + 0.0722 * B
return L
end
▲ L = return 0.2126 * R + 0.7152 * G + 0.0722 * B
-- failure
▲ error('Invalid hex color ' .. origc, 2)
end
|