Generative Art #159
Code
void setup() {
size(900, 900, P2D);
pixelDensity(2);
smooth(8);
rectMode(CENTER);
}
void draw() {
background(0);
tile(0, 0, width);
noiseFilter();
if (frameCount > 20)exit();
saveFrame("output/####.png");
}
void form(float x, float y, float s) {
float hs = s/2;
color col = getCol();
push();
translate(x, y);
fill(col);
noStroke();
square(0, 0, s);
for (int i=0; i<12; i++) {
float rx = random(-hs*0.9, hs*0.9);
float ry = random(-hs*0.9, hs*0.9);
fill(255);
beginShape();
vertex(hs+1, hs+1);
fill(col);
vertex(rx, hs);
vertex(hs, ry);
endShape(CLOSE);
rotate(HALF_PI);
}
pop();
}
void tile(float x_, float y_, float w_) {
int tileCount = (int)random(2, 4);
float tileWidth = w_/tileCount;
for (float x = x_; x < x_ + w_ -1; x += tileWidth) {
for (float y = y_; y < y_ + w_ - 1; y += tileWidth) {
if (random(1) < 0.2 && tileWidth > 100) {
tile(x, y, tileWidth);
} else {
form(x+tileWidth/2, y+tileWidth/2, tileWidth-5);
}
}
}
}
void noiseFilter(){
for (int i = 0; i < 500000; i ++) {
stroke(random(100, 255), 70);
strokeWeight(0.5);
point(random(width), random(height));
}
}
void mousePressed() {
redraw();
}
void keyPressed() {
if (key == 's')saveFrame("####.png");
}
//int[] colors = {#e06c9f, #f283b6, #a1bf65, #409975, #CF4DED};
int[] colors = {#52DBFF, #FA4949, #4968FA, #49FAD5, #49FAD5};
int getCol() {
return colors[(int)random(colors.length)];
}
Happy coding!
応援してくださる方!いつでもサポート受け付けてます!