-
Notifications
You must be signed in to change notification settings - Fork 1
/
__main__.py
71 lines (56 loc) · 1.52 KB
/
__main__.py
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
"""2024-11-29
Backlog IX
Grade composta por círculos coloridos
png
Sketch,py5,CreativeCoding
"""
import random
import py5
from utils import helpers
from utils.draw import cria_grade
sketch = helpers.info_for_sketch(__file__, __doc__)
random.seed(__file__)
MARGEM = 100
CELULA = 20
MEIA_CELULA = CELULA // 2
PALETA = [
"#F7D744",
"#D0341E",
"#D0341E",
"#120D2D",
"#425AC6",
"#CAC9D1",
]
def setup():
py5.size(helpers.LARGURA, helpers.ALTURA, py5.P3D)
py5.background(py5.random_choice(PALETA))
py5.rect_mode(py5.CORNERS)
py5.ellipse_mode(py5.CENTER)
py5.color_mode(py5.HSB, 360, 100, 100)
grade = cria_grade(800, 800, MARGEM, MARGEM, CELULA, CELULA, False)
with py5.push_style():
for passo in range(0, MARGEM):
inicio = (MARGEM - CELULA) + passo
final = (py5.width - MARGEM + CELULA) - passo
py5.stroke(py5.random_choice(PALETA))
py5.rect(inicio, inicio, final, final)
for x0, y0 in grade:
x = x0 + MEIA_CELULA
y = y0 + MEIA_CELULA
diametro = py5.random_int(MEIA_CELULA, CELULA)
cor = py5.random_choice(PALETA)
py5.stroke(cor)
cor = py5.random_choice(PALETA)
py5.fill(cor)
py5.circle(x, y, diametro)
helpers.write_legend(sketch=sketch)
def key_pressed():
key = py5.key
if key == " ":
save_and_close()
def save_and_close():
py5.no_loop()
helpers.save_sketch_image(sketch)
py5.exit_sketch()
if __name__ == "__main__":
py5.run_sketch()