日常の進捗

書くし、描くし、足掻くし

昨日は口頭発表の原稿提出日だった。なんとか出せた。

昨日は一日雨で塵が落ちたので、今日は空気が澄んでいた。

int grid = 20;
float[][] points;
PGraphics pg;

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

  pg = createGraphics(width, height);

  int numX = (int)(width/grid);
  int numY = (int)(height/grid);

  pg.beginDraw();
  pg.background(255);
  pg.fill(0);
  //pg.textFont(createFont("YuGothic-Bold", 200));
  pg.textSize(200);
  pg.textAlign(CENTER, CENTER);
  pg.text("SUMMER", pg.width/2, pg.height/2);
  pg.endDraw();

  points = new float[numX][numY];

  for (int i = 0; i < points.length; i++) {
    for (int j = 0; j < points[i].length; j++) {
      int x = grid * i;
      int y = grid * j;
      color c = pg.get(x, y);
      float value = map(brightness(c), 0, 100, 1.0, 0);
      color c1 = pg.get(x+grid/2, y);
      float value1 = map(brightness(c1), 0, 100, 1.0, 0);
      color c2 = pg.get(x-grid/2, y);
      float value2 = map(brightness(c2), 0, 100, 1.0, 0);
      color c3 = pg.get(x, y+grid/2);
      float value3 = map(brightness(c3), 0, 100, 1.0, 0);
      color c4 = pg.get(x, y-grid/2);
      float value4 = map(brightness(c4), 0, 100, 1.0, 0);
      points[i][j] = value + value1 + value2+ value3 + value4;
    }
  }
}

// draw関数 : setup関数実行後繰り返し実行される
void draw() {
  //image(pg, 0, 0);
  background(0, 0, 100);
  noStroke();
  fill(220, 80, 100, 20);
  for (int i = 0; i < points.length; i++) {
    for (int j = 0; j < points[i].length; j++) {
      int x = grid * i;
      int y = grid * j;
      if (x > grid && y > grid) {
        float r = map(points[i][j], 0, 5, 0, grid*2);
        float freqY = map(points[i][j], 0, 5, 0.003, 0.01);        
        if(r > 0){
        r += map(noise(x/100f,y/100f,frameCount*freqY),0,1,-grid,grid)
        }
        float valueX = sin(0.024*frameCount+(x+y*width)*0.0013)*r;
        float valueY = map(noise(x/100f,y/100f,frameCount*freqY),0,1,-grid,grid);
        ellipse(x+valueX, y+valueY, r, r);
      }
    }
  }
}