Skip to content

Instantly share code, notes, and snippets.

@hilukasz
Last active December 12, 2015 02:19
Show Gist options
  • Save hilukasz/4698364 to your computer and use it in GitHub Desktop.
Save hilukasz/4698364 to your computer and use it in GitHub Desktop.
void setup(){
makeTransition(fromRGB, toRGB, 1000);
//exit();
}
int time = 1000;
int[] fromRGB = { 100, 0, 255 };
int[] toRGB = { 50, 0, 0 };
void makeTransition(int[] fromRGB, int[] toRGB, int time){
for(int i = 0; i < 3; i++){ // loop through R,G,B
print("from: " +fromRGB[i]); println(", to: " +toRGB[i]);
if(fromRGB[i] != toRGB[i]){ // make sure they are not already at correct R, G, B
if(fromRGB[i] > toRGB[i]){
fromRGB[i]--;
} else { fromRGB[i]++;}
println(fromRGB[i]);
}
}
delay(time);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment