見出し画像

ProcessingでGenerative art #41

Code

void setup() {
  size(800, 500);
  pixelDensity(2);
  colorMode(HSB, 360, 100, 100, 100);
  strokeWeight(2);
  PFont myFont = loadFont("LiSongPro-60.vlw");
  textFont(myFont);
  textAlign(CENTER, CENTER);
  noLoop();
}

void draw() {
  number();
  for (int i = 0; i<10; i++) {
    drawCircle(random(width), random(height), random(400));
  }
}

void number() {
  background(212, 100, 100);
  for (int i = 0; i<3000; i++) {
    fill(212, random(100), random(100));
    textSize(random(20, 60));
    text(int(random(10)), random(width), random(height));
  }
}

void drawCircle(float _x, float _y, float d) {
  pushMatrix();
  translate(_x, _y);
  noStroke();
  float h = random(10, 50);
  color c1= color(h, 100, 50, 1);
  color c2= color(h, 2, 90, 1);
  for (float l = d; l > 0; l-=2) {
    color c = lerpColor(c1, c2, l / d);
    fill(c);
    ellipse(0, 0, l, l);
  }

  for (int i = int(random(50)); i < d; i+= random(100)) {
    noFill();
    stroke(random(1) > 0.5 ? 0 : 360);
    if (random(1)>0.5) {
      ellipse(0, 0, i, i);
    } else {
      float start = random(PI);
      float stop = start + random(PI*2);
      arc(0, 0, i, i, start, stop);
    }

    for (int j = 0; j < int(random(15)); j++) {
      rotate(random(PI*2));
      float len = random(1);
      if (len > 0.7) {
        line(0, 0, i/2, 0);
      } else if (len > 0.5) {
        line(i / 6, 0, i/2, 0);
      } else if (len > 0.3) {
        line(random(d/2), 0, d/2, 0);
      }
      noStroke();
      fill(random(1) > 0.5 ? 0 : 360);
      float dot = random(10);
      ellipse(i/2, 0, dot, dot);
    }
  }
  popMatrix();
}

void mousePressed() {
  redraw();
}

void keyPressed() {
  if (key == ' ')saveFrame("####.png");
}

応援してくださる方!いつでもサポート受け付けてます!