Module:ColourGen

From Ways of Darkness
Jump to navigation Jump to search

Documentation for this module may be created at Module:ColourGen/doc

function Colgen(num)
	local to_return = { }
	for i=1,num do
		local red = math.floor(1/num * i * 255)
		local green = math.floor(1/num * (num-i) * 255)
		local blue = math.floor(math.abs((1/num * i) - 0.5) * 255)
		to_return[i] = "#" .. string.format("%02x",red) .. string.format("%02x",green) .. string.format("%02x",blue)
	end
	return to_return
end

local p = { }
function p.Test(frame)
	local to_return = ""
	local colours = Colgen(6)
	for i=1,6 do
		to_return = to_return ..  "<font color=\"" .. colours[i]  .. "\">" .. i .. "</font> "
	end
	return to_return
end
return p