Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int alpha = 10;
- color[] colorArray = {color(0,0,0,alpha),color(255, 192, 0,alpha),color(200, 0, 0,alpha),color(126, 255, 0,alpha)};
- int currentColor;
- int nextColor;
- boolean change = false;
- void setup(){
- size(640,480);
- smooth();
- noStroke();
- currentColor = 0;
- }
- void draw(){
- //background(colorArray[currentColor]);
- fill(colorArray[currentColor]);
- rect(0, 0, 1000, 1000);
- if(change){
- currentColor = nextColor;
- change = false;
- }
- //println("change: "+change);
- }
- void keyReleased(){
- if(key == 's'){
- change = true;
- println("currentColor: "+currentColor);
- int newColor = currentColor;
- while (newColor == currentColor)
- newColor=(int) random(colorArray.length);
- nextColor = newColor;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment