Daily Creative Coding

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

ストライプにズームインする

/**
* zoom in to stripe
*
* @author aa_debdeb
* @date 2016/12/13
*/

int LOOP = 600;

void setup(){
  size(640, 480);
  rectMode(CENTER);
  noStroke();
  fill(255);
}

void draw(){
  background(0);
  float time = frameCount % LOOP;
  float lineWidth = map(pow(time / (LOOP - 1), 4), 0, 1, 0, 200);
  float lineGap = map(pow(time / (LOOP - 1), 3), 0, 1, 1, width + 200);
  float centerX = width / 2;
  int lineNum = int(centerX / lineGap);
  for(int x = 0; x <= lineNum; x++){
    rect(centerX + (x + 0.5) * lineGap, height / 2, lineWidth, height);
    rect(centerX - (x + 0.5) * lineGap, height / 2, lineWidth, height);
  }
  
}
f:id:aa_debdeb:20161209221713j:plain