見出し画像

Generative Art #184

画像1

画像2

画像3

画像4

Code

int[] hue = {192, 12};
//int[] hue = {160, 340};

void setup() {
 size(900, 900);
 pixelDensity(2);
 noLoop();
 colorMode(HSB, 360, 100, 100);
}

void draw() {
 rectRec(0, 0, width, height);
 noiseFilter();
 noiseSeed(int(random(100000)));
}

void rectRec(float x_, float y_, float w_, float h_) {
 int c = (int)random(2, 11);
 float w = w_/c;

 for (float x = x_; x < x_ + w_ -1; x += w) {
   for (float y = y_; y < y_ + h_ - 1; y += w) {
     if (random(1) < 0.8 && w > 10) {
       rectRec(x, y, w, w);
     } else {
       float ns = 0.01;
       int n = int(map(noise(x*ns, y*ns), 0, 1, 0, 2));
       int s = int(map(noise(x*ns, y*ns, w*ns*2), 0, 1, 60, 100));
       int b = int(map(noise(x*ns, y*ns, w*ns*2), 0, 1, 60, 100));
       color col = color(hue[n], s, b);
       fill(col);
       stroke(col);
       rect(x, y, w, w);
     }
   }
 }
}

void noiseFilter() {
 for (int i=0; i<500000; i++) {
   float x = random(width);
   float y = random(width);
   fill(360, 50);
   noStroke();
   circle(x, y, 0.5);
 }
}

void mousePressed() {
 redraw();
}

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

再帰的に分割した正方形を配置し、色の決定をnoise()に任せています。

何かもう一工夫しよう思い、いろいろ試しましたがうまくいかないので
ここからは未来の自分に託します。

Happy coding!

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