Daily Creative Coding

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

テクノ・ライト

/**
 * techno lights
 * 
 * @author aadebdeb
 * @date 2017/02/13
 */
 
function setup() {
  createCanvas(windowWidth, windowHeight);
  colorMode(HSB, 360, 100, 100)
  frameRate(30);
  noFill();
}

function draw() {
  background(0, 100, 0);
  strokeWeight(1);
  var isSine = true;
  for (var baseH = -50; baseH <= height + 50; baseH += 100) {
    stroke(random(360), 100, 100);
    beginShape(TRIANGLE_STRIP);
    var dir = 1;
    var sincos = isSine ? sin: cos;
    for (var w = 0; w <= width; w += 20) {
      var h = baseH + sincos(w * 0.01 + map(sincos(frameCount * 0.1), -1, 1, -PI, PI)) * 50 * dir;
      vertex(w, h);
      dir *= -1;
    }
    endShape();
    isSine = !isSine;
  }
}
f:id:aa_debdeb:20170209204004j:plain