Advertisement
here2share

# Tk_radial_sparse.py

Feb 22nd, 2022
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. # Tk_radial_sparse.py
  2.  
  3. import math
  4.  
  5. from tkinter import *
  6.  
  7. ww = 600
  8. hh = 600
  9.  
  10. root = Tk()
  11. root.title("Tk_radial_sparse")
  12. root.geometry("%dx%d+-10+0"%(ww,hh))
  13. canvas = Canvas(root, width=ww, height=hh)
  14. canvas.pack()
  15.    
  16. xy = []
  17. PI = math.pi
  18. ww0 = ww/2
  19. hh0 = hh/2
  20.  
  21. for r in range(1,500,5):
  22.     circumference = (r * 2 * PI) / ((r + 200.0) / 50)
  23.     if not circumference:
  24.         circumference = 1
  25.     for degrees in range(0,360,int(360.0/circumference)):
  26.         angle = math.radians(degrees)
  27.         x = int(r * math.cos(angle))+ww0
  28.         y = int(r * math.sin(angle))+hh0
  29.         if 0 < x < ww-3 and 0 < y < hh-3:
  30.             xy.append((x,y))
  31.             canvas.create_oval(x,y,x+3,y+3, fill="purple", outline="")
  32. canvas.update()
  33.  
  34. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement