Daily Creative Coding

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

サイン波を累乗する

/**
* exponential sine tooth
*
* @author aa_debdeb
* @date 2016/12/25
*/

void setup(){
  size(500, 500);
  noStroke();
}

void draw(){
  background(146, 250, 0);
  int[] powers = {2, 4, 10, 40};
  color[] colors = {color(200),
                    color(250, 0, 246),
                    color(200),
                    color(146, 250, 0)};
  for(int i = 1; i <= 4; i++){
    pushMatrix();
    translate(0, i * 100);
    fill(colors[i - 1]);
    beginShape();
    vertex(0, height);
    for(float w = 0; w <= width; w++){
      float time = frameCount * 0.3 + w * 0.2;
      float h = noise(time)  * map(pow(abs(sin(time)), powers[i - 1]), 0, 1, 0, -100);
      vertex(w, h);
    }
    vertex(width, height);
    endShape();
    popMatrix();  
  }
}
f:id:aa_debdeb:20161222214550j:plain