Advertisement
here2share

# Tk_rnd_multiplier_patterns_2.py

Jun 10th, 2019
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. # Tk_rnd_multiplier_patterns_2.py
  2.  
  3. import math
  4. import time
  5. from Tkinter import *
  6. import random
  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.     points2 = []
  16.     canvas.delete('all')
  17.     angleBetweenPoints = 360.0 / number_of_points
  18.     for i in range(number_of_points):
  19.         angle = i * angleBetweenPoints
  20.         a = x + outerradius * math.sin(angle*math.pi/180)
  21.         b = y + outerradius * math.cos(angle*math.pi/180)
  22.         aaa = x + innerradius * math.sin(angle*math.pi/180)
  23.         bbb = y + innerradius * math.cos(angle*math.pi/180)
  24.         points.append([a+10, b+10])
  25.         points2.append([aaa+10, bbb+10])
  26.     if points:
  27.         for i in range(len(points)):
  28.             x1,y1 = points[i]
  29.             x2,y2 = points2[i*multiplier % len(points)]
  30.             canvas.create_line(x1,y1,x2,y2)
  31.         canvas.update()
  32.  
  33.  
  34. x = 280
  35. y = 280
  36. outerradius = 275
  37. innerradius = 225
  38. points = []
  39. points2 = []
  40. wait = 0
  41.  
  42. while 1:
  43.     number_of_points = random.randint(60,360)
  44.     multiplier = random.randint(2,number_of_points-1)
  45.     drawCircle()
  46.     print number_of_points, multiplier
  47.     wait = time.time()+0.6
  48.     while time.time() < wait:
  49.         0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement