-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__main__.py
More file actions
103 lines (84 loc) · 2.62 KB
/
Copy path__main__.py
File metadata and controls
103 lines (84 loc) · 2.62 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
"""2026-05-26
Crescimento 14
Grade com círculos concêntricos
ericof.com|https://ericof.com/en/sketches/2024-07-30
png
Sketch,py5,CreativeCoding
"""
from sketches.utils.draw import canvas
from sketches.utils.draw.grade import cria_grade
from sketches.utils.helpers import sketches as helpers
import py5
sketch = helpers.info_for_sketch(__file__, __doc__)
cor_fundo = py5.color(0)
GRADE = []
celula_x = 200
celula_y = 200
num_circulos_por_celula = 1
circ_min = 5
circ_max = 20
traco_min = 1
traco_max = 5
POS = [
(celula_x / 2, celula_y / 2),
]
def calcula_grade():
grade = cria_grade(*helpers.DIMENSOES.internal, 0, 0, celula_x, celula_y, False)
for x, y in grade:
fundo = py5.color("#EADDCC")
circulos = []
for _ in range(num_circulos_por_celula):
num_circulos = py5.random_int(circ_min, circ_max)
pos = py5.random_choice(POS)
for _ in range(num_circulos):
tamanho = py5.random_int(2, celula_x)
passo = py5.TWO_PI / py5.random_int(2, 22)
cor = py5.color(cor_fundo)
traco = py5.random_int(traco_min, traco_max)
circulos.append((pos, tamanho, cor, traco))
GRADE.append(((x, y), fundo, passo, circulos))
def setup():
py5.size(*helpers.DIMENSOES.external, py5.P3D)
py5.color_mode(py5.RGB)
calcula_grade()
def draw():
py5.background(cor_fundo)
f = py5.frame_count
with py5.push():
py5.translate(*helpers.DIMENSOES.pos_interno, -10)
for i, ((x, y), fundo, passo, circulos) in enumerate(GRADE):
with py5.push():
py5.stroke(cor_fundo)
py5.stroke_weight(4)
py5.fill(fundo)
xi, xf = x, celula_x
yi, yf = y, y + celula_y
py5.rect(xi, yi, xf, yf)
with py5.push():
py5.translate(x, y, 0)
for circulo in circulos:
(xc, yc), d, cor, traco = circulo
s = py5.cos(py5.radians(f * 2) + i * passo)
d += 65 * s
py5.no_fill()
py5.stroke(cor)
py5.stroke_weight(traco)
py5.circle(xc, yc, d)
# Credits and go
canvas.sketch_frame(
sketch,
cor_fundo,
"large_transparent_white",
"transparent_white",
version=2,
)
def key_pressed():
key = py5.key
if key == " ":
save_and_close()
def save_and_close():
py5.no_loop()
canvas.save_sketch_image(sketch)
py5.exit_sketch()
if __name__ == "__main__":
py5.run_sketch()