見出し画像

Generative Art #183

画像1

画像2

画像3

画像4

画像5

Code

void setup() {
 size(900, 900);
 pixelDensity(2);
 noLoop();
}

void draw() {
 background(getCol());
 push();
 translate(width/2, height/2);
 rotate(PI/random(1));
 translate(-width, -height);
 tile();

 pop();

 rectRec(0, 0, width, height, 5);

 //saveFrame("output/####.png");
 //if (frameCount > 50)exit();
}

void tile() {
 int c = 50;
 float w = width*2/c;

 noStroke();
 for (int j=0; j<c; j++) {
   for (int i=0; i<c; i++) {
     float ns = 0.003;
     float ww = noise(i*w*ns, j*w*ns)*w*2;
     fill(getCol());
     myCircle(i*w+w/2, j*w+w/2, ww);
   }
 }
 noiseSeed(int(random(100000)));
}

void myCircle(float x, float y, float d) {
 stroke(0);
 for (float i=d; i>0; i-=10) {
   fill(getCol());
   circle(x, y, i);
   noStroke();
 }
}

void rectRec(float x, float y, float w, float h, int n) { 
 noFill();
 stroke(255);
 strokeWeight(2);
 rect(x, y, w, h);
 
 stroke(0);
 strokeWeight(1);
 rect(x, y, w, h);

 n--;

 if (n>=0) {
   if (w>=h) {
     float randomW = random(w*0.1, w*0.9);
     rectRec(x, y, randomW, h, n);
     rectRec(x+randomW, y, w-randomW, h, n);
   }
   if (w<h) {
     float randomH = random(h*0.1, h*0.9);
     rectRec(x, y, w, randomH, n);
     rectRec(x, y+randomH, w, h-randomH, n);
   }
 }
}

void mousePressed() {
 redraw();
}

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

int[] colors = {#ffe74c, #ff5964, #ffffff, #38618c, #35a7ff};
int getCol() {
 return colors[(int)random(colors.length)];
}

前回と似たような構造です。
円の大きさをnoise()で制御しています。

円をタイル状に並べました。同心円はランダムに配色し一番大きな円にのみstroke()を適用しています。

全体の角度をランダムにずらしているのは最近のお気に入りです。

上から再帰的に分割した矩形を描画しています。四角形を2つ重ねることでストロークに縁取りをしました。

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