Skip to content

Commit adae4c7

Browse files
author
renzon
committed
Rotação Ok
1 parent a7ef37e commit adae4c7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

placa_grafica_tkinter.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import time
33
from tkinter import PhotoImage, NW, Tk, Canvas, Label
44
from tkinter.constants import ALL
5+
import math
56
import atores
67

78
from fase import Fase
@@ -43,12 +44,15 @@ def animar(tela, camada_de_atores, fase, passo=0.01, delta_t=0.01):
4344
angulo = 0
4445

4546
def _animar():
47+
nonlocal tempo
48+
nonlocal angulo
4649
camada_de_atores.delete(ALL)
4750
camada_de_atores.create_image((0, 0), image=BACKGROUND, anchor=NW)
48-
nonlocal tempo
4951
tempo += delta_t
52+
tamanho_seta=40
53+
angulo_rad=math.radians(-angulo)
5054

51-
camada_de_atores.create_line(52, 493, 100 + angulo / 10, 493 - angulo, width=1.5)
55+
camada_de_atores.create_line(52, 493, 52 + tamanho_seta*math.cos(angulo_rad), 493 + tamanho_seta*math.sin(angulo_rad), width=1.5)
5256
camada_de_atores.create_text(35, 493, text=u"%d°" % angulo)
5357
for ponto in fase.calcular_pontos(tempo):
5458
plotar(camada_de_atores, ponto)

0 commit comments

Comments
 (0)