見出し画像

Generative Art #197

画像1

画像2

画像3

画像4

Code

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

void draw() {
 background(0);
 tile();
}

void tile() {
 int c = int(random(5, 21));
 float w = width/c;

 noStroke();
 stroke(255);
 strokeWeight(1);
 for (int j=0; j<=c; j++) {
   for (int i=0; i<=c; i++) {
     float rnd = random(0.7);
     noFill();
     ellipse(i*w, j*w, w*rnd, w*rnd);
     fill(255);
     ellipse(i*w, j*w, 1, 1);
   }
 }
 noFill();
 stroke(0);
 for (int j=0; j<=c; j++) {
   for (int i=0; i<=c; i++) {
     form(i*w+w/2, j*w+w/2, w);
   }
 }
}

void form(float x, float y, float s) {
 float hs = s/2;
 float sw = s*0.1;
 int p = int(random(2));
 float len = s*0.13;
 noFill();
 strokeWeight(s*0.01);
 stroke(255);
 for (int j=0; j<2; j++) {
   push();
   translate(x, y);
   if (p == 0) {
     rotate(HALF_PI);
   }
   rotate(PI*j);
   translate(-hs, -hs);
   push();
   beginShape();
   vertex(hs + len*0.35, 0);
   vertex(hs + len*0.35, +len*0.5);
   vertex(hs - len*0.35, +len*0.5);
   vertex(hs - len*0.35, 0);
   endShape();
   for (int i=0; i<3; i++) {
     rotate(HALF_PI/4);
     rect(hs, 0, len*0.6, len);
   }
   rotate(HALF_PI/4);
   beginShape();
   vertex(hs + len*0.35, 0);
   vertex(hs + len*0.35, -len*0.5);
   vertex(hs - len*0.35, -len*0.5);
   vertex(hs - len*0.35, 0);
   endShape();

   pop();
   rotate(-HALF_PI/8);
   for (int i=0; i<4; i++) {
     rotate(HALF_PI/4);
     line(hs, len/2, hs, -len/2);
   }
   pop();
 }
}

void mousePressed() {
 redraw();
}

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

int[] colors = {};
int getCol() {
 return colors[(int)random(colors.length)];
}

鎖のパターン

Happy coding !!

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