Module:ColorFormatConverter

From Rock Revolution Wiki

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

local p = {}

function p.hexToRGB(frame)
	local hexCode = string.gsub(frame.args[1], "#", "")
	local r = tonumber(hexCode:sub(1, 2), 16)
	local g = tonumber(hexCode:sub(3, 4), 16)
	local b = tonumber(hexCode:sub(5, 6), 16)
	
	return r .. ", " .. g .. ", " .. b
end

function p.rgbToHex(frame)
	local r, g, b = frame.args[1], frame.args[2], frame.args[3]	
	return string.format("%X%X%X", r, g, b)
end

return p