Help with smooth blending from one colour to another

Hi, I have an image on my title screen that I would like to change smoothly from one colour to another, cycling through the colours of the rainbow. Not sure if I’ve explained that very well, but as an example…
http://www.youtube.com/watch?v=77zn_wO1osM
I realise it would have to be done with the object:setFillColor command, but can’t seem to work out how best to do the cycling.

(hope this makes sense) [import]uid: 7841 topic_id: 24714 reply_id: 324714[/import]

Hey Appletreeman,

This could use some definite cleaning up but try running it, it should give you a base that you can work from, I hope;

[lua]local r, g, b = 0, 0, 0
local goRed, goBlue, goYellow
local circle = display.newCircle( 160, 240, 60 )

goRed = function()
r = r + 5
if g > 0 then g = g-5 end
if b > 0 then b = b-5 end
if r == 255 then
timer.performWithDelay(10, goBlue, 51)
end
circle:setFillColor(r, g, b)
end
timer.performWithDelay(10, goRed, 51)

goBlue = function()
b = b + 5
if r > 0 then r = r - 5 end
if g > 0 then g = g - 5 end
if b == 255 then
timer.performWithDelay(10, goYellow, 51)
end
circle:setFillColor(r, g, b)
end

goYellow = function()
r = r + 5
g = g + 5
if b > 0 then b = b - 5 end
if r == 255 and g == 255 then
timer.performWithDelay(10, goRed, 51)
end
circle:setFillColor(r, g, b)
end[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 24714 reply_id: 100276[/import]

Oooh ta muchly for that. I’ll give it a try as soon as I get chance :slight_smile:
[import]uid: 7841 topic_id: 24714 reply_id: 100376[/import]

No worries, it’s pretty rough but hopefully it helps get you started :slight_smile: [import]uid: 52491 topic_id: 24714 reply_id: 100500[/import]