Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Changing color background

edited December 2011 in Code Sharing Posts: 2,820

Here is some code that I made that makes the background of your app change colors:

function setup()
    --displayMode(FULLSCREEN_NO_BUTTONS)
end

phase = 0

changingpace = .1

function changeBackground()
    bgr = 128+ 127 * math.sin(phase / (2*math.pi))
    bgg = 128+ 127 * math.sin(phase * 2/ (2*math.pi))
    bgb = 128+ 127 * math.sin(phase * 3/ (2*math.pi))
    
    phase = phase + changingpace
    
    if phase > (360 * 6) then
        phase = 0
    end
    background(bgr, bgg, bgb, 255)
end


function draw()
    changeBackground()
end
Sign In or Register to comment.