Daily Creative Coding

元「30 min. Processing」。毎日、Creative Codingします。

サイケデリック

/**
* Psychedelia
* 
* @author aa_debdeb
* @date 2015/12/31
*/

int rectNum = 200;
ArrayList<Integer> colors;

void setup(){
  size(500, 500);
  rectMode(CENTER);
  colorMode(HSB, 360, 100, 100);
  noStroke();
  frameRate(45);
  
  colors = new ArrayList<Integer>();
  for(int i = 0; i < rectNum; i++){
    colors.add(color(random(360), random(50) + 50, random(50) + 50)); 
  }
}

void draw(){
  float wStep = float(width) / rectNum;
  float hStep = float(height) / rectNum;
  for(int i = 0; i < rectNum; i++){
   color c = colors.get(rectNum - i - 1);
   if(frameCount % 2 == 0){
     fill(c);
   } else {
     fill(hue(c) < 180 ? hue(c) + 180 : hue(c) - 180, saturation(c), brightness(c));
   }
   rect(width / 2, height / 2, width - wStep * i, height - hStep * i); 
  }
  colors.remove(0);
  colors.add(color(random(360), random(50) + 50, random(50) + 50));
}