Created
April 26, 2017 21:13
-
-
Save iUltimateLP/0b263ba46e7d2f8b28551c9a4b6bd1b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hsvToRgb(h, s, v, a) | |
local r, g, b | |
local i = math.floor(h * 6); | |
local f = h * 6 - i; | |
local p = v * (1 - s); | |
local q = v * (1 - f * s); | |
local t = v * (1 - (1 - f) * s); | |
i = i % 6 | |
if i == 0 then r, g, b = v, t, p | |
elseif i == 1 then r, g, b = q, v, p | |
elseif i == 2 then r, g, b = p, v, t | |
elseif i == 3 then r, g, b = p, q, v | |
elseif i == 4 then r, g, b = t, p, v | |
elseif i == 5 then r, g, b = v, p, q | |
end | |
return {red = r * 255, green = g * 255, blue = b * 255, alpha = a * 255} | |
end | |
curHue = 0 | |
function update() | |
if curHue + 1 > 360 then | |
curHue = 0 | |
else | |
curHue = curHue + 1 | |
end | |
local color = hsvToRgb(curHue / 360,1,1,1) | |
self.setColorTint({r = color["red"] / 255, g = color["green"] / 255, b = color["blue"] / 255}) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment