-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__main__.py
111 lines (95 loc) · 2.78 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
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
104
105
106
107
108
109
110
111
"""2025-02-09
MSX Lives 03
Logo do MSX e cores básicas de um MSX 1
png
Sketch,py5,CreativeCoding
"""
from pathlib import Path
import py5
from utils import helpers
from utils.draw import cria_grade_ex, gera_octagono
sketch = helpers.info_for_sketch(__file__, __doc__)
LOGO_FILE = Path(__file__).parent / "msx-logo.svg"
PALETA = [
"#000000",
"#010101",
"#3eb849",
"#74d07d",
"#5955e0",
"#8076f1",
"#b95e51",
"#65dbef",
"#db6559",
"#ff897d",
"#ccc35e",
"#ded087",
"#3aa241",
"#b766b5",
"#cccccc",
"#ffffff",
]
def desenha_fundo():
passo = py5.height // len(PALETA)
x0, xf = -py5.width * 2, py5.width * 2
with py5.push_matrix(), py5.push_style():
py5.translate(0, 0, -80)
py5.no_stroke()
for idy, y in enumerate(range(0, py5.height, passo)):
y0 = y - passo
yf = y + 2 * passo
py5.fill(PALETA[idy])
py5.rect(x0, y0, xf, yf)
def setup():
py5.size(helpers.LARGURA, helpers.ALTURA, py5.P3D)
py5.background(0)
desenha_fundo()
py5.color_mode(py5.HSB, 360, 100, 100)
py5.rect_mode(py5.CENTER)
forma = py5.load_shape(LOGO_FILE)
aspect_ratio = forma.width / forma.height
celula_largura = 150
celula_altura = celula_largura
forma_largura = celula_largura * 0.8
forma_altura = forma_largura / aspect_ratio
grade = cria_grade_ex(py5.width, py5.height, 100, 100, 150, 150, False)
h = 245
py5.shape_mode(py5.CENTER)
for idx, x, idy, y in grade:
fundo = gera_octagono()
s = py5.remap(idy, 0, 3, 50, 91)
b = py5.remap(idx, 0, 3, 50, 97)
with py5.push_matrix():
py5.translate(x, y, -60)
with py5.push_style():
fundo.set_stroke(py5.color(h, s, b * 0.9))
fundo.set_stroke_weight(5)
fundo.set_fill(py5.color(h, s, b))
py5.shape(
fundo,
celula_largura * 1.2,
celula_altura / 2,
celula_largura,
celula_altura,
)
py5.shape_mode(py5.CENTER)
py5.no_stroke()
for idx, xb, idy, yb in grade:
x = xb + celula_largura / 2
y = yb + celula_altura / 2
with py5.push_matrix():
py5.translate(x, y, -60)
with py5.push_style():
py5.fill(py5.color(100, 0, 0))
py5.rect(0, 0, forma_largura, forma_altura)
py5.shape(forma, 0, 0, forma_largura, forma_altura)
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()