Daily Creative Coding

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

斜め線のフロー

/**
* line floaw
*
* @author aa_debdeb
* @date 2017/01/16
*/

float STEP = 20;

void setup(){
  size(640, 640);
  noFill();
}

void draw(){
  background(39, 26, 32);
  for(float d = 0; d <= width * 2; d += STEP){
    float diff = map(sin((d) * 0.03 - frameCount * 0.1), -1, 1, -STEP / 2, STEP / 2);
    float rate = map(abs(sin((d) * 0.03 - frameCount * 0.1)), 0, 1, 0, 1);
    stroke(lerpColor(color(170, 133, 70), color(102, 136, 158), rate));
    strokeWeight(2);
    beginShape();
    for(float x = d + STEP; x >= -STEP; x -= 5){
      float y = d - x + diff;
      vertex(x, y);
    }
    endShape();
  }
}
f:id:aa_debdeb:20170111210527j:plain