Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_wave_dict.py
- import tkinter as tk
- from PIL import Image, ImageDraw, ImageTk
- import math
- WW = 600
- HH = 600
- root = tk.Tk()
- root.geometry(f"{WW}x{HH}+0+0")
- canvas = tk.Canvas(root, width=WW, height=HH)
- canvas.pack()
- def polar_to_cartesian(radius, degrees):
- radians = math.radians(degrees)
- x = int(radius * math.cos(radians))
- y = int(radius * math.sin(radians))
- return x, y
- xy = {}
- xy[0] = []
- for radius in range(2, 801):
- for degrees in range(0, 360):
- xy[(radius, degrees)] = polar_to_cartesian(radius, degrees)
- xy[0] += [(radius, degrees)]
- def slide_dots():
- canvas.move('dot', -5, 0)
- xy[0].pop(0)
- xy[0].pop(0)
- xy[0].pop(0)
- xy[0].pop(0)
- radius, degrees = xy[0].pop(0)
- x, y = xy[(radius, degrees)]
- canvas.create_rectangle(WW-2, HH//2+y-2, WW-2+4, HH//2+y+2, fill="red", outline='', tags="dot")
- root.update()
- root.after_idle(slide_dots)
- slide_dots()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement