Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_combo_polygons.py
- from random import shuffle, randrange
- from itertools import combinations
- from time import time
- try:
- from Tkinter import *
- except:
- from tkinter import *
- root = Tk()
- ww = 600
- hh = 600
- canvas = Canvas(root, width=ww, height=hh, bg='white')
- canvas.pack()
- t = 30
- y = t
- outer = [(x,y) for x in range(t,ww,t)]
- y = hh-t
- outer = [(x,y) for x in range(t,ww,t)] + outer
- t = 70
- x = t
- outer = [(x,y) for y in range(t,hh,t)] + outer
- x = ww-t
- outer = [(x,y) for y in range(t,hh,t)] + outer
- L = len(outer)/2
- inner = [(int(x*0.8)+50,int(y*0.5)+145) for x,y in outer]
- t = 7
- c_inner = combinations(inner[::-3], t)
- c_outer = combinations(outer[::-7], t)
- for cO in c_outer:
- L = len(cO)
- for cI in c_inner:
- points = sum([[cI[(i+3)%L],cO[i]] for i in range(L)],[])
- t = time()+0.1
- canvas.delete('all')
- canvas.create_polygon(points,fill='yellow',outline='black')
- canvas.update()
- while time() < t:
- 0
Add Comment
Please, Sign In to add comment