Guest User

alpha fade that weirdly works

a guest
Sep 20th, 2016
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. int alpha = 10;
  3. color[] colorArray  = {color(0,0,0,alpha),color(255, 192, 0,alpha),color(200, 0, 0,alpha),color(126, 255, 0,alpha)};
  4. int currentColor;
  5. int nextColor;
  6.  
  7. boolean change = false;
  8.  
  9. void setup(){
  10.     size(640,480);
  11.     smooth();
  12.     noStroke();
  13.     currentColor = 0;
  14. }
  15. void draw(){
  16.     //background(colorArray[currentColor]);
  17.     fill(colorArray[currentColor]);
  18.     rect(0, 0, 1000, 1000);
  19.  
  20.     if(change){
  21.  
  22.         currentColor = nextColor;
  23.         change = false;
  24.        
  25.     }
  26.     //println("change: "+change);
  27. }
  28. void keyReleased(){
  29.     if(key == 's'){
  30.         change = true;
  31.         println("currentColor: "+currentColor);
  32.         int newColor = currentColor;
  33.         while (newColor == currentColor)
  34.         newColor=(int) random(colorArray.length);
  35.         nextColor = newColor;
  36.     }
  37. }
RAW Paste Data