Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_flippant.py
- from Tkinter import *
- import math, random, time
- rndi = random.randint
- print
- ww = 1200
- hh = 600
- center = ww/2, hh/2
- c = Canvas(width=ww, height=hh, bg='white')
- c.pack()
- outer = [(x,0) for x in range(ww)]+[(ww,y) for y in range(hh)]+[(x,hh) for x in range(ww)[::-1]]+[(0,y) for y in range(hh)[::-1]]
- outerL = len(outer)-1
- speed = []
- for z in range(-200,200):
- t = int(z*0.1)
- if t:
- speed += [t]
- speed += speed[1:-1][::-1]
- speedL = len(speed)
- i = 1
- t = outerL/2
- points = []
- for xy in range(0,outerL,outerL/60):
- points += [(xy-((i%2)*t),rndi(0,speedL))]
- i += 1
- prev = 0
- while 1:
- delay = time.time()+0.05
- c.delete('all')
- polygon = []
- for i,zzz in enumerate(points):
- xy, sp = zzz
- sp += rndi(1,3)
- sp %= speedL
- xy += speed[sp]
- xy %= outerL
- polygon += [outer[int(xy)]]
- prev = (xy+outerL/2)%outerL
- points[i] = xy, sp
- c.create_polygon(polygon, fill='black', outline='white', width=10)
- while delay > time.time():
- c.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement