日常の進捗

主に自分のための,行為とその習慣化の記録

ノイズと円

今日は軽め。終端の0度と360度のつなぎ目の部分がうまく行かなかった。

int m = 60;
float step = 360 / m;
// setup関数 : 初回1度だけ実行される
void setup() {
  fullScreen(); // ウィンドウサイズを960px,540pxに
  colorMode(HSB, 360, 100, 100, 100); // HSBでの色指定にする
  smooth(); // 描画を滑らかに
}

// draw関数 : setup関数実行後繰り返し実行される
void draw() {
  fill(0, 0, 100, 10);
  rect(0, 0, width, height);
  noFill();
  strokeWeight(1);
  translate(width/2, height/2);
  for (float r1 = 0; r1 < 500; r1 += 20) {
    stroke(0,0,r1%100);
    rotate(r1*0.001);
    int n = 0;
    beginShape();
    for (float angle = 0; angle < 360; angle = angle + step) {
      float r = map(noise(r1*0.04, angle*0.15, frameCount*0.01), -1, 1, r1-r1*0.2, r1+r1*0.2);
      float theta = radians(angle);
      float x = cos(theta) * r;
      float y = sin(theta) * r;
      curveVertex(x, y);
      if (n == 0) {
        curveVertex(x, y);
      }
      if (n == m-1) {
        float r0 = map(noise(0*0.05, frameCount*0.01), -1, 1, 50, 200);
        float theta0 = radians(0);
        float x0 = cos(theta0) * r;
        float y0 = sin(theta0) * r;

        float r360 = map(noise(350*0.05, frameCount*0.01), -1, 1, 50, 200);
        float theta360 = radians(360);
        float x360 = cos(theta360) * r;
        float y360 = sin(theta360) * r;

        float x2 = lerp(x0, x360, 0.5); 
        float y2 = lerp(y0, y360, 0.5); 
        //curveVertex(x2, y2);
        curveVertex(x0, y0);
        curveVertex(x0, y0);
      }
      n = n + 1;
    }
    endShape();
  }
}