Advertisement
here2share

# Tk_multiplier_patterns.py

Jun 8th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. # Tk_multiplier_patterns.py
  2.  
  3. import math
  4. import time
  5. from Tkinter import *
  6. from PIL import ImageTk
  7.  
  8. root = Tk()
  9. width,height=600,600
  10. canvas = Canvas(root,width=width, height=height, background="grey" )
  11. canvas.pack()
  12.  
  13. def drawCircle():
  14.     points = []
  15.     canvas.delete('all')
  16.     angleBetweenPoints = 360.0 / number_of_points
  17.     for i in range(number_of_points):
  18.         angle = i * angleBetweenPoints
  19.         pointx = x + radius * math.sin(angle*math.pi/180)
  20.         pointy = y + radius * math.cos(angle*math.pi/180)
  21.         points.append([pointx+10, pointy+10])
  22.  
  23.     for i in range(len(points)):
  24.         x1,y1 = points[i]
  25.         x2,y2 = points[i*multiplier % len(points)]
  26.         canvas.create_line(x1,y1,x2,y2)
  27.     canvas.update()
  28.  
  29.  
  30. x = 280
  31. y = 280
  32. radius = 275
  33. points = []
  34. wait = 0
  35.  
  36. while 1:
  37.     for number_of_points in range(10,360):
  38.         for multiplier in range(2,number_of_points-1):
  39.             drawCircle()
  40.             print number_of_points, multiplier
  41.             wait = time.time()+0.6
  42.             while time.time() < wait:
  43.                 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement