Advertisement
here2share

# tk_wave_dict.py

Jan 13th, 2025
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. # tk_wave_dict.py
  2.  
  3. import tkinter as tk
  4. from PIL import Image, ImageDraw, ImageTk
  5. import math
  6.  
  7. WW = 600
  8. HH = 600
  9.        
  10. root = tk.Tk()
  11. root.geometry(f"{WW}x{HH}+0+0")
  12.  
  13. canvas = tk.Canvas(root, width=WW, height=HH)
  14. canvas.pack()
  15.  
  16. def polar_to_cartesian(radius, degrees):
  17.     radians = math.radians(degrees)
  18.     x = int(radius * math.cos(radians))
  19.     y = int(radius * math.sin(radians))
  20.     return x, y
  21.  
  22. xy = {}
  23. xy[0] = []
  24. for radius in range(2, 801):
  25.     for degrees in range(0, 360):
  26.         xy[(radius, degrees)] = polar_to_cartesian(radius, degrees)
  27.         xy[0] += [(radius, degrees)]
  28.  
  29. def slide_dots():
  30.     canvas.move('dot', -5, 0)
  31.     xy[0].pop(0)
  32.     xy[0].pop(0)
  33.     xy[0].pop(0)
  34.     xy[0].pop(0)
  35.     radius, degrees = xy[0].pop(0)
  36.     x, y = xy[(radius, degrees)]
  37.     canvas.create_rectangle(WW-2, HH//2+y-2, WW-2+4, HH//2+y+2, fill="red", outline='', tags="dot")
  38.     root.update()
  39.     root.after_idle(slide_dots)
  40.  
  41. slide_dots()
  42.  
  43. root.mainloop()
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement