local getArgs = require('Module:Arguments').getArgs local p =
local function makeInvokeFunction(funcName) return function (frame) local args = getArgs(frame,) return p[funcName](args) endend
p.spectrum = makeInvokeFunction('_spectrum')function p._spectrum(args) local list = mw.text.split(args[1], '\n') local width = tonumber(args[2]) or tonumber(args.width) or 768 local pos,length,rgb,red,green,blue,gray,neargray,title local result = '
' for i1, v1 in ipairs(list) do for i2, v2 in ipairs(mw.text.split(v1, '\\')) do -- i.1:Name; i.2:RGB if (i2 % 2
' elseif (i2 % 2
6 or string.len(v2)
Invalid RGB value. Please use "RRGGBB" or "RGB" formats and all numbers must be converted to hexadecimal.
' else if string.len(v2)
green and red
' else if red > green and red > blue then -- red if blue > green then pos = width - (width / 6) * (blue - green) / (red - green) -- magenta to red elseif green > blue then pos = (width / 6) * (green - blue) / (red - blue) -- red to yellow else pos = 0 end elseif green > red and green > blue then -- green if red > blue then pos = width / 3 - (width / 6) * (red - blue) / (green - blue) -- yellow to green elseif blue > red then pos = width / 3 + (width / 6) * (blue - red) / (green - red) -- green to cyan else pos = width / 3 end elseif blue > red and blue > green then -- blue if green > red then pos = width * 2 / 3 - (width / 6) * (green - red) / (blue - red) -- cyan to blue elseif red > green then pos = width * 2 / 3 + (width / 6) * (red - green) / (blue - green) -- blue to magenta else pos = width * 2 / 3 end elseif red
blue then -- cyan pos = width / 2 elseif blue
' end result = result .. '
' end if pos < 0 then pos = 5 else pos = '-' .. pos end result = result .. '
' .. title .. ': ' .. string.upper(rgb) .. ' ' if gray' end end end end result = result .. '
' local colori = for i, v in ipairs(colori) do local colorin = '
' .. v .. '
' if width < 768 then if (i % 2)
'end
return p