Daily Creative Coding

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

変調されたパーリンノイズ

/**
 * modulated perlin noise
 * 
 * @author aadebdeb
 * @date 2017/03/08
 */

function setup() {
  createCanvas(windowWidth, windowHeight);
  mousePressed();
}

function mousePressed() {
  
  var nscale = 0.002;
  var nbaseX = random(10000);
  var nbaseY = random(10000);
  var mscale = 0.01;
  var mbaseXX = random(10000);
  var mbaseXY = random(10000);
  var mbaseYX = random(10000);
  var mbaseYY = random(10000);
  var colors = [
    color(0, 27, 55),
    color(31, 36, 70),
    color(42, 16, 45),
    color(148, 127, 40),
    color(230, 167, 50)
  ];
  
  for (var w = 0; w < width; w++) {
    for (var h = 0; h < height; h++) {
      var modX = map(noise(w * mscale + mbaseXX, h * mscale + mbaseXY), 0, 1, -3, 3);
      var modY = map(noise(w * mscale + mbaseYX, h * mscale + mbaseYY), 0, 1, -3, 3);
      var n = noise(w * nscale + nbaseX + modX, h * nscale + nbaseY + modY);
      var v = map(sin(map(n, 0, 1, 0, TWO_PI)), -1, 1, 0, 1);
      var ci = int(v * (colors.length - 1));
      stroke(lerpColor(colors[ci], colors[ci + 1], v * (colors.length - 1) - ci));
      point(w, h);
    }
  }
}

function draw() {
  
}
f:id:aa_debdeb:20170304211446j:plain