local p = {}
function p.main(frame)
local args = frame:getParent().args
local colors = {}
local i = 1
while args[i] and args[i] ~= '' do
table.insert(colors, args[i])
i = i + 1
end
if #colors == 0 then
return ''
end
local average = 100 / #colors
local stops = {}
table.insert(stops, colors[1] .. ' ' .. average .. '%')
for j = 2, #colors do
table.insert(stops, colors[j] .. ' ' .. average * (j - 1) .. '%')
table.insert(stops, colors[j] .. ' ' .. average * j .. '%')
end
local gradient = table.concat(stops, ', ')
local result = 'background-image:-webkit-linear-gradient(left, ' .. gradient .. '); ' ..
'background-image:-moz-linear-gradient(left, ' .. gradient .. '); ' ..
'background-image:-o-linear-gradient(left, ' .. gradient .. '); ' ..
'background-image:linear-gradient(to right, ' .. gradient .. ');'
return result
end
return p