見出し画像

Processingでnoise()を試す(1)

今後の参考用にProcessingでnoise()のパラメータによる変化を試してみた。
コードは以下のとおり
noise()のパラメータの増え幅を変えて試してみました

float step = 10;
int marginleft = 120;
int marginright = 50;
float y=100;

void setup(){
  size(700, 1200);
  background(255);
  strokeWeight(3);
  smooth();
  fill(0);
  textSize(20);
  
  int x=marginleft;
  text("Normal", 30, y);
  line(x, y, width-marginright, y);
  
  noiseLine(0.01);
  noiseLine(0.02);
  noiseLine(0.03);
  noiseLine(0.04);
  noiseLine(0.05);
  noiseLine(0.06);
  noiseLine(0.07);
  noiseLine(0.08);
  noiseLine(0.09);
  noiseLine(0.1);
}

void noiseLine(float ynoise){
  float lastx=-999;
  float lasty=-999;
  float stepy=ynoise;
  
  translate(0, 100);
  text(str(ynoise), 30, 100);
  
  for(int x=marginleft; x<=width-marginright; x+=step){
    y = 50 + noise(ynoise)*50;
    if(lastx>-999){
      line(x, y, lastx, lasty);
    }
    lastx = x;
    lasty = y;
    ynoise+=stepy;
  }
}

結果は以下のとおり

増え幅が大きくなるほどランダム性は強くなるけど、違いがみられるのはだいたい0.05~0.5の間ぐらい。