Skip to content

Instantly share code, notes, and snippets.

@rajubd49
Created April 16, 2015 13:03
Show Gist options
  • Save rajubd49/e6f9aff28099e12a1d40 to your computer and use it in GitHub Desktop.
Save rajubd49/e6f9aff28099e12a1d40 to your computer and use it in GitHub Desktop.
How to rotate through a selection of colors - Appcelerator Titanium
var win = Ti.UI.createWindow({
fullscreen: true,
backgroundColor: 'blue',
});
setInterval(function(){
var backColor = win.backgroundColor;
if(backColor == 'blue'){
win.animate({backgroundColor: 'purple', duration: 1500});
win.backgroundColor = 'purple';
};
if(backColor == 'purple'){
win.animate({backgroundColor: 'red', duration: 1500});
win.backgroundColor = 'red';
};
if(backColor == 'red'){
win.animate({backgroundColor: 'orange', duration: 1500});
win.backgroundColor = 'orange';
};
if(backColor == 'orange'){
win.animate({backgroundColor: 'yellow', duration: 1500});
win.backgroundColor = 'yellow';
};
if(backColor == 'yellow'){
win.animate({backgroundColor: 'green', duration: 1500});
win.backgroundColor = 'green';
};
if(backColor == 'green'){
win.animate({backgroundColor: 'blue', duration: 1500});
win.backgroundColor = 'blue';
};
backColor = win.backgroundColor;
}, 2000);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment