Generative Art #117
Code
void setup() {
size(840, 840);
pixelDensity(2);
noLoop();
strokeCap(SQUARE);
}
void draw() {
background(#ffffff);
tile();
}
void form(float x, float y, float s) {
fill(getCol());
noStroke();
square(x, y, s);
for (float i = x; i < x + s; i += random(10)) {
if (random(1) > 0.5) {
stroke(getCol());
strokeWeight(random(20));
if (random(1) > 0.5) {
line(i, y, i, y + s);
} else {
float yMap = map(i, x, x + s, y, y + s);
line(x, yMap, x + s, yMap);
}
}
}
}
void tile() {
int count = int(random(3, 12));
float w = width/count;
noFill();
stroke(0);
for (int j = 0; j < count; j++) {
for (int i = 0; i < count; i++) {
form(i*w, j*w, w);
}
}
}
int[] colors = {#320E3B, #E56399, #7F96FF, #A6CFD5, #A30015};
int getCol() {
return colors[(int)random(colors.length)];
}
void keyPressed() {
if (key == 's')saveFrame("####.png");
}
void mousePressed() {
redraw();
}
正方形の範囲内に縦か横に線を引いてそれを充填させた。
Happy coding!!
応援してくださる方!いつでもサポート受け付けてます!