-
Notifications
You must be signed in to change notification settings - Fork 1
/
__main__.py
84 lines (71 loc) · 2.16 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
"""2024-09-12
Colorful waves 09
Padrão de ondas coloridas, mas que poderiam ser teares
png
Sketch,py5,CreativeCoding
"""
from collections import deque
import numpy as np
import py5
from utils import helpers
sketch = helpers.info_for_sketch(__file__, __doc__)
PALETA = deque(
[
"#7ec0e0",
"#1c8eaf",
"#032035",
"#fdaa08",
"#f87109",
]
)
def setup():
py5.size(helpers.LARGURA, helpers.ALTURA)
py5.background(252, 249, 230)
py5.rect_mode(py5.CORNERS)
py5.stroke_weight(2)
py5.no_fill()
passos = 30
lx = py5.width
ly = py5.height // 2
x = np.linspace(-lx, lx, endpoint=False, num=py5.width * 2)
y = np.linspace(-ly + 10, ly + 10, endpoint=True, num=passos)
multiplicadores = np.logspace(1.2, 1.4, num=passos // 2, endpoint=False)
multiplicadores = sorted(multiplicadores, reverse=True) + sorted(multiplicadores)
pesos = np.linspace(1, 4, num=passos // 2, endpoint=False)
pesos = sorted(pesos) + sorted(pesos, reverse=True)
y = zip(y, multiplicadores, pesos)
with py5.push_matrix():
py5.translate(lx, ly)
for yb, mult_b, peso in y:
y0 = None
x0 = 0
py5.stroke_weight(peso)
for idx, x1 in enumerate(x):
xd = py5.remap(x1, -lx, lx, -60, 40)
mult = mult_b * py5.cos(py5.radians(xd))
yd = mult * (
abs(
py5.sin(py5.radians(x1 + (3 * yb)))
* py5.cos(x1)
* py5.sin(py5.radians(x0))
)
)
y1 = yb + yd if (idx % 2) else yb - yd
py5.stroke(PALETA[0])
if y0 is None:
y0 = y1
py5.circle(x0, y0, peso)
x0, y0 = x1, y1
PALETA.rotate(1)
helpers.write_legend(sketch=sketch, frame="#000", cor="#FFF")
save_and_close()
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()