Daily Creative Coding

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

ノイジーなパーリンノイズ

/**
 * noisy perlin noise
 * 
 * @author aadebdeb
 * @date 2017/03/10
 */

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

function mousePressed() {
  var nscale = 0.004;
  var noffsetX = random(10000);
  var noffsetY = random(10000);
  var noffsetZ = random(10000);
  var mscale = 0.03;
  var moffsetX = random(10000);
  var moffsetY = random(10000);
  for (var w = 0; w < width; w++) {
    for (var h = 0; h < height; h++) {
      var m = noise(w * mscale + moffsetX, h * mscale + moffsetY);
      var mz = abs(randomGaussian(0, map(pow(m, 5), 0, 1, 0, 2)));
      var n = noise(w * nscale + noffsetX, h * nscale + noffsetY, mz + noffsetZ);
      var v = map(sin(map(n, 0, 1, 0, TWO_PI * 2)), -1, 1, 0, 1);
      if (v < 0.5) {
        stroke(lerpColor(color(0), color(30), map(v, 0, 0.5, 0, 1)));
      } else {
        stroke(lerpColor(color(30), color(195, 216, 45), map(v, 0.5, 1, 0, 1)));
      }
      point(w, h);
    }
  }
}

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