Differenze tra le versioni di "Modulo:ChooseColor"

Vai alla navigazione Vai alla ricerca
Refactoring of ChooseColor (damn recursive protection)
(Adding a function for Pokémon types *** sovrascritto il testo esistente ***)
(Refactoring of ChooseColor (damn recursive protection))
local tab = require('Modulo:Wikilib/tables') -- luacheck: no unused
local w = require('Modulo:Wikilib')
local multigen = require('Modulo:Wikilib/multigen')
local colorMod = mw.loadData('Modulo:Colore/data')
local colorschemeMod = mw.loadData('Modulo:Colorscheme/data')
local pdpokes = requiremw.loadData('Modulo:PokémonDataPoké/data')
 
local function _checkCol(col)
end
 
-- givenGiven a background hex color, return the most appropriate text color. Lua
-- interface
p.forBg = function(frame)
p.forBgLua = function(bgColor)
local bgColor = frame.args[1]
 
local bgR = _checkCol(tonumber(bgColor:sub(1, 2), 16) / 255)
local bgG = _checkCol(tonumber(bgColor:sub(3, 4), 16) / 255)
return 'white-text'
end
end
-- givenGiven twoa background hex colorscolor, return the most appropriate text color
p.forBg = function(frame)
return p.forBgLua(frame.args[1])
end
 
-- givenGiven a background module color, return the most appropriate text color. Lua
-- interface
p.forModBg = function(frame)
p.forModBgLua = function(color, shade)
local args = w.trimAll(frame.args)
local shade = args[2]shade or 'normale'
local color = args[1]
local shade = args[2] or 'normale'
 
local colorHex = colorMod[color][shade]
 
return p.forBg{args={forBgLua(colorHex}})
end
-- givenGiven twoa background module colorscolor, return the most appropriate text color
 
p.forModBg = function(frame)
-- 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 =return p.forModBgLua(args[1], args[2])
end
local c2 = args[2]
 
-- Given two background hex colors, return the most appropriate text color
-- calculated on the midpoint
p.forGradBgLua = function(c1, c2)
local c1R = tonumber(c1:sub(1, 2), 16)
local c1G = tonumber(c1:sub(3, 4), 16)
local midpointHex = string.format('%x%x%x', R, G, B)
 
return p.forBg{args={forBgLua(midpointHex}})
end
-- Given two background hex colors, return the most appropriate text color
 
-- calculated on the midpoint
-- given two background module colors, return the most appropriate text color
p.forModGradBgforGradBg = function(frame)
local args = w.trimAll(frame.args)
return p.forGradBgLua(args[1], args[2])
local col1 = args[1]
end
local col2 = args[2] or args[1]
 
-- Given two background module colors, return the most appropriate text color.
if col1 == col2 then
-- Lua interface
return p.forModBg{args={col1}}
p.forModGradBgLua = function(col1, col2)
-- return p.forGradBg{args={colorMod[col1]['light'], colorMod[col2]['normale']}}
if (not col2) or (col1 == col2) then
return p.forModBg{args={forModBgLua(col1}})
else
return p.forGradBg{args={forGradBgLua(colorMod[col1]['.normale'], colorMod[col2]['.normale']}})
end
end
-- Given two background module colors, return the most appropriate text color
p.forGradBgforModGradBg = function(frame)
local bgColorargs = w.trimAll(frame.args[1])
return p.forModGradBgLua(args[1], args[2] or args[1])
end
 
-- Given two background colorscheme names, return the most appropriate text
-- same as above but with colorscheme
-- color
p.forModCsGradBg = function(frame)
local args = w.trimAll(frame.args)
local hex2 = colorschemeMod[col]['dark']
 
return p.forGradBg{args={forGradBgLua(hex1, hex2}})
end
 
local gen = args.gen or ''
 
local type1 = pdmultigen.getType1{args={getGenValue(pokes[poke].type1, gen = gen}})
local type2 = pdmultigen.getType2{args={getGenValue(pokes[poke].type2, gen = gen}})
 
return p.forModGradBg{args={forModGradBgLua(type1, type2}})
end
 

Menu di navigazione