Daily Creative Coding

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

線の波

/**
* waving lines
*
* @author aa_debdeb
* @date 2016/03/27
*/

float noiseW, noiseH, noiseT;

void setup(){
  size(500, 500);
  
  stroke(255, 200);
  strokeWeight(1);
  noFill();
  
  noiseW = random(100);
  noiseH = random(100);
  noiseT = random(100);
}

void draw(){
  background(0);
  float t = frameCount * 0.03;
  for(float h = -100; h < height + 100; h += 3){
    beginShape();
    curveVertex(0, h + getNoise(0, h, t));
    for(float w = 0; w <= width; w += 20){
      curveVertex(w, h + getNoise(w, h, t));
    }
    curveVertex(width, h + getNoise(width, h, t));
    endShape();
  } 
}

float getNoise(float w, float h, float t){
  return map(noise(noiseW + w * 0.01, noiseH + h * 0.01, noiseT + t), 0, 1, -100, 100);
}