Advertisement
here2share

# Tk_rnd_multiplier_loverlap.py

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