Display Object Color Transition

Vote up!

transition.to doesn't seem to support color transitions. So I made one myself using enterFrame, which is how I suspect corona's transition library works too.

Simply import the file into your project and require the file. Aternatively, copy the function to somewhere you'd prefer if you don't want a global function called "TransitionColor"

Usage is similar to the transition.to function (for sake of my sanity and yours)

-- setup
local rect = display.newRect(50,50,100,100)

-- usage
TransitionColor(rect, {
    startColor = {0,0,0,0},
    endColor = {1,1,1,1},
    time = 500,
    transition = easing.outCubic

The function will not affect your object if no options table is given.

Options table MUST contain startColor and endColor values.
Colors should be constructed as a table containing the r,g,b,a fields. Alpha channel is optional.

time value will default to 300 if none is passed in the options table.

Corona's easing library is supported and will default to easing.linear if no transition value is passed in the options table.
See the Corona easing API for more.
See the colorInterpolate function in the code to find out how to implement your own!

You can easily extend this to add onStart/onComplete event callbacks, and pause/resume functionality.
(I will do it myself once I get some spare time, but this is all I need for my project right now)

Works with Corona build #: