-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__main__.py
76 lines (59 loc) · 1.69 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
72
73
74
75
76
"""2025-02-06
Hexagons 6
Estudo sobre hexágonos e padrões
png
Sketch,py5,CreativeCoding
"""
import py5
from utils import helpers
from utils.draw import cria_grade_ex, gera_hexagono
sketch = helpers.info_for_sketch(__file__, __doc__)
CELULA_X = helpers.LARGURA / 10
CELULA_Y = CELULA_X * 0.8
PALETA = [
"#F7D744",
"#D0341E",
"#120D2D",
"#425AC6",
"#CAC9D1",
]
COR_1 = "#D0341E"
COR_2 = "#120D2D"
def seleciona_cor(idx: int, idy: int) -> str:
cor = ""
if idy % 2:
cor = COR_1 if idx % 3 == 0 else COR_2
else:
cor = COR_1 if idx % 3 == 1 else COR_2
return cor
def setup():
py5.size(helpers.LARGURA, helpers.ALTURA, py5.P3D)
py5.background(248, 241, 219)
py5.shape_mode(py5.CENTER)
grade = cria_grade_ex(py5.width * 4, py5.height * 4, 0, 0, CELULA_X, CELULA_Y, True)
forma = gera_hexagono()
forma.set_stroke_weight(3)
with py5.push_matrix():
py5.translate(0, -30, -60)
cor = py5.color(30, 30, 30)
for idx, x, idy, y in grade:
cor_base = seleciona_cor(idx, idy)
for i, diff in enumerate([8, 12]):
tamanho = CELULA_X - diff
forma.set_stroke(cor)
if i:
forma.set_fill(py5.color(cor_base))
else:
forma.set_fill(py5.color(248, 241, 219))
py5.shape(forma, x, y, tamanho, tamanho)
helpers.write_legend(sketch=sketch, cor="#CCC", frame="#333")
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()