見出し画像

Generative Art #191

画像1

画像2

画像3

Code

void setup() {
 size(800, 800);
 pixelDensity(2);
 noLoop();
 rectMode(CENTER);
}

void draw() {
 background(0);
 noStroke();
 tile();
 noiseSeed(int(random(10000)));
}

void tile() {
 int count = 20;
 float s = width/count;
 for (int j = 0; j < count; j++) {
   for (int i = 0; i < count; i++) {
     float x = i*s+s/2;
     float y = j*s+s/2;
     fill(colors[0]);
     square(x, y, s);
     fill(colors[1]);
     rects(x, y, s);
     shuffleCol();
   }
 }
}


void rects(float x, float y, float s) {
 float nScl = 0.003;
 float count = int(noise(x*nScl, y*nScl)*8);
 float ss = s/count;
 push();
 translate(x-(s/2), y-(s/2));
 for (float j = 0; j < count; j++) {
   for (float i =0; i < count; i++) {
     float xx = i * ss + ss / 2;
     float yy = j * ss + ss / 2;
     square(xx, yy, ss*0.8);
   }
 }
 pop();
}

int[] shuffleCol() {
 int[] array = colors;
 int n = array.length;
 int i, t;
 while (n > 0) {
   n--;
   i = int(random(n));
   t = array[n];
   array[n] = array[i];
   array[i] = t;
 }
 return array;
}

void mousePressed() {
 redraw();
}

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

int[] colors = {#ffffff, #140d4f, #2ab7ca, #ee2677, #0cce6b};
int getCol() {
 return colors[(int)random(colors.length)];
}

Happy coding!

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