here2share

# Tk_combo_polygons.py

Feb 7th, 2021 (edited)
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. # Tk_combo_polygons.py
  2.  
  3. from random import shuffle, randrange
  4. from itertools import combinations
  5. from time import time
  6.  
  7. try:
  8.     from Tkinter import *
  9. except:
  10.     from tkinter import *
  11.    
  12. root = Tk()
  13. ww = 600
  14. hh = 600
  15. canvas = Canvas(root, width=ww, height=hh, bg='white')
  16. canvas.pack()
  17.  
  18. t = 30
  19. y = t
  20. outer = [(x,y) for x in range(t,ww,t)]
  21. y = hh-t
  22. outer = [(x,y) for x in range(t,ww,t)] + outer
  23.  
  24. t = 70
  25. x = t
  26. outer = [(x,y) for y in range(t,hh,t)] + outer
  27. x = ww-t
  28. outer = [(x,y) for y in range(t,hh,t)] + outer
  29. L = len(outer)/2
  30.  
  31. inner = [(int(x*0.8)+50,int(y*0.5)+145) for x,y in outer]
  32.  
  33. t = 7
  34. c_inner = combinations(inner[::-3], t)
  35. c_outer = combinations(outer[::-7], t)
  36.  
  37. for cO in c_outer:
  38.     L = len(cO)
  39.     for cI in c_inner:
  40.         points = sum([[cI[(i+3)%L],cO[i]] for i in range(L)],[])
  41.         t = time()+0.1
  42.         canvas.delete('all')
  43.         canvas.create_polygon(points,fill='yellow',outline='black')
  44.         canvas.update()
  45.         while time() < t:
  46.             0
Add Comment
Please, Sign In to add comment