알고리즘 아트

어디서 본 그림인데 기억이 안난다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
void setup() {
size(500, 500);
background(255);
smooth();
noFill();
noLoop();
ellipseMode(RADIUS);
}
void draw() {
rule1(width / 2, height / 2, 400);
blend(createCircleMask(200), 0, 0, width, height, 0, 0, width, height, ADD);
}
void rule1(float x, float y, float r) {
if (r < 25) {
return;
}
strokeWeight(r / 100);
ellipse(x, y, r, r);
float hr = r / 2;
rule1(x, y, hr);
for (int t = 30; t < 360 + 30; t += 60) {
float c = hr * cos(radians(t));
float s = hr * sin(radians(t));
rule1(x + c, y + s, hr);
}
}
PGraphics createCircleMask(float r) {
PGraphics mask = createGraphics(width, height);
mask.beginDraw();
mask.background(255);
mask.noStroke();
mask.fill(0);
mask.ellipseMode(RADIUS);
mask.ellipse(width / 2, height / 2, r, r);
mask.endDraw();
return mask;
}
Share Comments