import tkinter as tk
import math
W = H = 858
root = tk.Tk()
root.title("Animation")
canvas = tk.Canvas(root, width=W, height=H, bg="black", highlightthickness=0)
canvas.pack()
p = [
("gray", 0.3, 45, 0.47, 35),
("orange", 0.7, 72, 0.35, 42),
("blue", 0.8, 108, 0.3, 78),
("red", 0.5, 144, 0.24, 84),
("brown", 1.5, 198, 0.13, 98),
("yellow", 1.2, 252, 0.1, 52),
("light blue", 0.1, 306, 0.07, 76),
("blue", 0.1, 360, 0.05, 360),
]
b = []
for c, sz, t, sb, inc in p:
b.append([c, sz * 20, t, sb, math.radians(inc), 0, 0, 0])
h_angle = 0
objects = []
def draw_circle(x, y, r, color):
return canvas.create_oval(x - r, y - r, x + r, y + r, fill=color, outline=color)
def animate():
global h_angle
canvas.delete("all")
for j, d in enumerate(b):
d[5] += d[3]
r = math.radians(d[5])
x = d[2] * math.cos(r)
y = d[2] * math.sin(r)
i = d[4]
px = x - y * 0.5
py = y * math.cos(i) * math.sin(i) + (x + y * math.cos(i) * 0.866) * 0.5
draw_circle(W / 2 + px, H / 2 + py, max(2, d[1]), d[0])
if j == 2:
hx = W / 2 + px + 15 * math.cos(h_angle)
hy = H / 2 + py + 15 * math.sin(h_angle)
draw_circle(hx, hy, 6, "white")
h_angle += 0.5
root.after(16, animate)
animate()
root.mainloop()

Nincsenek megjegyzések:
Megjegyzés küldése