Generative Art #114
Code
int count = 15;
void setup() {
size(840, 840);
pixelDensity(2);
noLoop();
}
void draw() {
background(#46767C);
lineRec(200, 200, 300, count);
circles();
}
void lineRec(float x, float y, float l, int n) {
float rl = random(l * 0.1, l * 0.5);
noStroke();
fill(getCol());
rect(x, y, l, rl);
n--;
if (n >= 0) {
float shift1 = random(l/5, l);
float shift2 = random(l - l/5);
float p = map(n, 0, count-1, 0.2, 1);
l = l*random(0.8, 1);
if (random(1) < p) {
pushMatrix();
translate(x + shift1, y + rl);
rotate(HALF_PI);
lineRec(0, 0, l, n);
popMatrix();
}
if (random(1) < p) {
pushMatrix();
translate(x + shift2, y);
rotate(-HALF_PI);
lineRec(0, 0, l, n);
popMatrix();
}
}
}
void circles() {
for (int i = 0; i < 25; i ++) {
float x = random(width);
float y = random(height);
float d = random(150);
fill(getCol(), random(100, 255));
circle(x, y, d);
}
}
int[] colors = {#E6C229, #F17105, #D11149, #6610F2, #1A8FE3, #3DE0A6};
int getCol() {
return colors[(int)random(colors.length)];
}
void mousePressed() {
redraw();
}
void keyPressed() {
if (key == 's')saveFrame("####.png");
}
僕は色決める時にこんなの使ったりもしていますよ。
5色スパッと並べてカラーコード表示してくれるので便利ですよ。
今回はこれから配色決めてないけどね。
もっと配色を追求したい。ちゃんと学問として色を学ぼうかなーって思ったり、めんどくさかったり。
Happy coding!
応援してくださる方!いつでもサポート受け付けてます!