Differenze tra le versioni di "Modulo:ChooseColor"

Vai alla navigazione Vai alla ricerca
nessun oggetto della modifica
(mw.loadData invece di require per il modulo Colore)
end
 
-- given a background hex color, return the most appropriate text color
p.forBg = function(frame)
local bgColor = frame.args[1]
end
 
-- given a background module color, return the most appropriate text color
p.forModBg = function(frame)
local args = w.trimAll(frame.args)
local colorHex = colorMod[color][shade]
return p.forBg{args={colorHex}}
end
 
-- given two background hex colors, return the most appropriate text color
-- calculated on the midpoint
p.forGradBg = function(frame)
local args = w.trimAll(frame.args)
local c1 = args[1]
local c2 = args[2]
local c1R = tonumber(c1:sub(1, 2), 16)
local c1G = tonumber(c1:sub(3, 4), 16)
local c1B = tonumber(c1:sub(5, 6), 16)
local c2R = tonumber(c2:sub(1, 2), 16)
local c2G = tonumber(c2:sub(3, 4), 16)
local c2B = tonumber(c2:sub(5, 6), 16)
local R = (c1R + c2R) / 2
local G = (c1G + c2G) / 2
local B = (c1B + c2B) / 2
local midpointHex = string.format('%x%x%x', R, G, B)
return p.forBg{args={midpointHex}}
end
 
-- given two background module colors, return the most appropriate text color
-- calculated on the midpoint
p.forModGradBg = function(frame)
local args = w.trimAll(frame.args)
local color1 = colorMod[args[1]]()
local color2 = colorMod[args[2]]()
return p.forGradBg{args={color1, color2}}
end
 

Menu di navigazione