Generative Art #198
Code
void setup() {
size(800, 800);
pixelDensity(2);
noLoop();
}
void draw() {
background(0);
noStroke();
for(int i=0; i<300000; i++){
float x = random(width);
float y = random(height);
float nScl = 0.004;
float alph = noise(x*nScl, y*nScl)*255;
fill(255, alph);
circle(x, y, random(1));
}
divideRect(0, 0, width, height, 200);
noiseSeed(int(random(100000)));
}
void divideRect(float x, float y, float w, float h, int min) {
if (w + h > min) {
strokeWeight(0.2);
stroke(getCol());
if (w >= h) {
float rndW = random(1) * w;
myLine(x+rndW, y, x+rndW, y+h);
divideRect(x, y, rndW, h, min);
divideRect(x + rndW, y, w - rndW, h, min);
} else {
float rndH = random(1) * h;
myLine(x, y+rndH, x+w, y+rndH);
divideRect(x, y, w, rndH, min);
divideRect(x, y + rndH, w, h - rndH, min);
}
} else if(w*0.9 < h && h < w*1.1) {
noFill();
strokeWeight(0.5);
stroke(getCol());
myCircle(x+w/2, y+h/2, w*0.8);
}
}
void myLine(float x1, float y1, float x2, float y2){
int c = int(random(10, 50));
float off = 5;
for(int i=0; i<c; i++){
float xoff1 = x1+random(-1, 1)*off;
float yoff1 = y1+random(-1, 1)*off;
float xoff2 = x2+random(-1, 1)*off;
float yoff2 = y2+random(-1, 1)*off;
line(xoff1, yoff1, xoff2, yoff2);
}
}
void myCircle(float x, float y, float d){
int c = int(random(5, 20));
int off = 5;
for(int i=0; i<c; i++){
float xoff = x+random(-1, 1)*off;
float yoff = y+random(-1, 1)*off;
float w = random(-1, 1)*off+d;
float h = random(-1, 1)*off+d;
ellipse(xoff, yoff, w, h);
}
}
void mousePressed() {
redraw();
}
void keyPressed() {
if (key == 's')saveFrame("####.png");
}
int[] colors = {#ffbe0b,#fb5607,#ff006e,#8338ec,#25768d};
int getCol() {
return colors[(int)random(colors.length)];
}
再帰的に分割した矩形の線を人の手でしゃこしゃこ描いたような表現にしてみました。
矩形の縦と横の長さが同じぐらいのときに円を描画しています。
Happy coding!
応援してくださる方!いつでもサポート受け付けてます!