Differenze tra le versioni di "Modulo:ChooseColor"

Vai alla navigazione Vai alla ricerca
Adding a function for Pokémon types *** sovrascritto il testo esistente ***
(Improving color choose)
(Adding a function for Pokémon types *** sovrascritto il testo esistente ***)
local colorMod = mw.loadData('Modulo:Colore/data')
local colorschemeMod = mw.loadData('Modulo:Colorscheme/data')
local pd = require('Modulo:PokémonData')
 
local function _checkCol(col)
p.forBg = function(frame)
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)
local bgB = _checkCol(tonumber(bgColor:sub(5, 6), 16) / 255)
 
local L = (0.1426 * bgR) + (0.6152 * bgG) + (0.0512 * bgB)
 
if L > 0.24 then
return 'black-text'
local color = args[1]
local shade = args[2] or 'normale'
 
local colorHex = colorMod[color][shade]
 
return p.forBg{args={colorHex}}
end
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.15
local G = (c1G + c2G) / 2.10
local B = (c1B + c2B) / 2.15
 
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 args = w.trimAll(frame.args)
local col = args[1]
 
local hex1 = colorschemeMod[col]['light']
local hex2 = colorschemeMod[col]['dark']
 
return p.forGradBg{args={hex1, hex2}}
end
 
-- when colors are types of a Pokémon; accepts both ndex and name
p.forPokeTypes = function(frame)
local args = w.trimAll(frame.args)
local poke = args[1]
local gen = args.gen or ''
 
local type1 = pd.getType1{args={poke, gen = gen}}
local type2 = pd.getType2{args={poke, gen = gen}}
 
return p.forModGradBg{args={type1, type2}}
end
 
270 477

contributi

Menu di navigazione