Created
February 2, 2013 18:12
-
-
Save hilukasz/4698649 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int time = 1000; | |
int[] fromRGB = { 100, 0, 255 }; | |
int[] toRGB = { 50, 0, 0 }; | |
void setup() { | |
makeTransition(fromRGB, toRGB, 1000); | |
} | |
boolean singleStep(int[] fromRGB,int[] toRGB) { | |
boolean keepGoing = true; | |
for(int i = 0; i < 3; ++i){ | |
keepGoing |= (fromRGB[i] != toRGB[i]); | |
fromRGB[i] += ((fromRGB[i] > toRGB[i]) ? -1 : 1); | |
println(fromRGB[i]); | |
} | |
return keepGoing; | |
} | |
void makeTransition(int[] fromRGB,int[] toRGB,int time){ | |
while(singleStep(fromRGB, toRGB)){ | |
delay(time); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment