Generative Art #104
Code
int count = 5;
void setup() {
size(840, 840);
pixelDensity(2);
noLoop();
}
void draw() {
background(0);
squareRec(10, 10, width-20, count);
}
void squareRec(float x, float y, float s, int n) {
noStroke();
fill(getCol());
square(x, y, s);
myCircle(x+s/2, y+s/2, s);
n--;
if (n >= 0) {
float probability = map(n, 0, count-1, 0.8, 0);
float hs = s/2;
if (random(1) > probability) {
squareRec(x, y, hs, n);
}
if (random(1) > probability) {
squareRec(x+hs, y, hs, n);
}
if (random(1) > probability) {
squareRec(x+hs, y+hs, hs, n);
}
if (random(1) > probability) {
squareRec(x, y+hs, hs, n);
}
}
}
void myCircle(float x, float y, float d) {
circleLine(x, y, d);
circleLine(x, y, d/2);
}
void circleLine(float x, float y, float s) {
fill(getCol());
circle(x, y, s);
pushMatrix();
stroke(getCol());
translate(x, y);
rotate(random(TAU));
for (float i = -s/2; i <= s/2; i+=5) {
beginShape();
for (float j = -s/2; j <= s/2; j+=3) {
float distans = dist(i, j, 0, 0);
if (distans <= s/2) {
vertex(i, j);
}
}
endShape();
}
popMatrix();
}
int[] colors = {#4392F1, #FFFFFF, #006494, #262626, #DC493A};
int getCol() {
return colors[(int)random(colors.length)];
}
void mousePressed() {
redraw();
}
void keyPressed(){
if(key == 's')saveFrame("####.png");
}
本当は円にピシッとまっすぐ線を引きたかったが予測していない歪みが出た。
これはこれで手書き感というかいい質感なので即採用。
簡単にいうと点と点を線で結んで、その線でザザザッと四角形作って、中心からの一定の距離(半径)の分だけを描画するってアプローチをした。
角度変えなきゃ割とまっすぐな線なんだけど。
本来の目的の円の中だけピシっと線を引くってどうやるかは思いついてない。また考えるとしよう。
それと画像加工してノイズを加えて粒子感を少し出した。
ここ最近のインスタとかで写真に粒子加工しているのって面白い流れだよね。
これだけ画質が上がったのにあえて、レトロ感を出すなんて。
Happy coding!
応援してくださる方!いつでもサポート受け付けてます!