-
Notifications
You must be signed in to change notification settings - Fork 1
/
__main__.py
75 lines (62 loc) · 1.88 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
"""2024-01-24
Genuary 24 - Impossible objects.
Dois Triângulos de Penrose concêntricos.
png
Sketch,py5,CreativeCoding,genuary,genuary24
"""
import py5
from utils import helpers
sketch = helpers.info_for_sketch(__file__, __doc__)
def face(lado: int = 100, angulo: int = 0, hb: int = 0):
passos = [
(0, lado),
(120, lado * 5),
(120, lado * 6),
(60, lado),
(120, lado * 5),
(-120, lado * 3),
]
x = 0
y = 0
forma = py5.create_shape()
with forma.begin_closed_shape():
for idx, (incremento, tamanho) in enumerate(passos):
angulo += incremento
x += py5.cos(py5.radians(angulo)) * tamanho
y += py5.sin(py5.radians(angulo)) * tamanho
forma.vertex(x, y)
for idx in range(forma.get_vertex_count()):
h = hb + idx * 10
forma.set_stroke(idx, py5.color(h, 0, 0))
forma.set_fill(idx, py5.color(h, 80, 100))
return forma
def setup():
py5.size(helpers.LARGURA, helpers.ALTURA, py5.P2D)
py5.background(252, 249, 230)
py5.color_mode(py5.HSB, 360, 100, 100)
py5.shape_mode(py5.CORNER)
with py5.push_matrix():
py5.translate(400, 400)
passos = [
(50, 225, 0, 38, -18, 5),
(50, 210, 120, -11, 64, 5),
(50, 205, 240, -57, -18, 5),
(10, 125, 0, 0, 2, 2),
(10, 110, 120, -10, 22, 2),
(10, 105, 240, -20.0, 2, 2),
]
for lado, h, angulo, x, y, peso in passos:
py5.stroke_weight(peso)
forma = face(lado, angulo, h)
py5.shape(forma, x, y)
helpers.write_legend(sketch=sketch, cor="#000")
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()