見出し画像

Generative Art #192

画像1

画像2

画像3

画像4

Code

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

void draw() {
 background(#D22E2C);
 for (int i=0; i<8; i++) {
   float x = random(width);
   float y = random(height);
   float s = random(100, 350);
   float alph = 255;
   noFill();
   strokeWeight(1);
   myCircle(x, y, s, int(s/2));
   stroke(0);
   strokeWeight(0.5);
   fill(getCol(), alph);
   ellipse(x, y, s, s);
 }
 
 for(int i=0; i<10; i++){
   float x = random(width);
   float y = random(height);
   float s = random(100, 500);
   noStroke();
   form(x, y, s);
 }
 
 for (int i=0; i<20; i++) {
   float x = random(width);
   float y = random(height);
   float s = random(20, 110);
   float alph = random(255);
   noFill();
   strokeWeight(1);
   myCircle(x, y, s, int(s/2));
   stroke(0);
   strokeWeight(0.5);
   fill(getCol(), alph);
   ellipse(x, y, s, s);
 }
}

void myCircle(float x, float y, float d, int c) {
 color col = getCol();
 for (int i=0; i<c; i++) {
   float dd = map(i, 0, c-1, d, d*1.4);
   float alph = map(i, 0, c-1, 100, 0);
   stroke(col, alph);
   ellipse(x, y, dd, dd);
 }
}

void form(float x, float y, float s) {
 float a = QUARTER_PI*(int(random(8)));
 color col = getCol();
 int c = int(s*0.3);
 push();
 translate(x, y);
 rotate(a);
 fill(col, 4);
 for (int i=0; i<c; i++) {
     float ss = map(i, 0, c-1, 0, s*1.5);
     beginShape();
     vertex(0, ss);
     vertex(0, 0);
     vertex(ss, 0);
     endShape(CLOSE);
 }
 pop();
}

void mousePressed() {
 redraw();
}

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

int[] colors = {#ca549e, #ea6828, #2055a7, #EDEDED, #43b26a, #D22E2C};
int getCol() {
 return colors[(int)random(colors.length)];
}

Happy coding!

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