Skip to content

Instantly share code, notes, and snippets.

@flamendless
Created June 28, 2018 06:20
Show Gist options
  • Save flamendless/9624ae310c0b21c2388715243bfb8130 to your computer and use it in GitHub Desktop.
Save flamendless/9624ae310c0b21c2388715243bfb8130 to your computer and use it in GitHub Desktop.
local Colors = {
RESET = {1,1,1,1},
WHITE = {1,1,1},
BLACK = {0,0,0},
RED = {1,0,0},
GREEN = {0,1,0},
BLUE = {0,0,1},
}
local setup_args = function(args, tween)
--ease, delay, onstart, onupdate, oncomplete
for k,v in pairs(args) do
if tween[k] then
tween[k](tween, v)
end
end
end
function Colors:get(c, a)
local t = UTILS.tableCopy(self[string.upper(c)])
t[4] = a or 1
return t
end
function Colors:fade(kind, color_obj, args)
local limit
if kind == "out" then limit = 0
elseif kind == "in" then limit = 1
end
--local t = self:get(c, a)
local tween = MODULES.flux.to(color_obj, args.time, { [4] = limit })
setup_args(args, tween)
return {
color = color_obj,
tween = tween,
}
end
function Colors:fade_loop(start, color_obj, args)
local last
if start == 1 then last = 0
elseif start == 0 then last = 1
end
local tween = MODULES.flux.to(color_obj, args.time, { [4] = last })
:oncomplete(function()
self:fade_loop(last, color_obj, args)
end)
setup_args(args, tween)
return {
color = color_obj,
tween = tween,
}
end
return Colors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment