Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_2D_Waves_Of_Four_2.py
- from PIL import Image, ImageTk, ImageDraw
- from Tkinter import *
- import PIL
- import math
- import random
- from itertools import permutations
- many = 4
- L = range(72,450,9)
- COMBOS = [z for z in permutations(L, many)]
- random.shuffle(COMBOS)
- COMBOS = [z for zzz in COMBOS for z in zzz]
- ww = 1400
- hh = 700
- waves = {}
- def PiXY(i,j):
- incr = (360.0/i)
- waves[j] = []
- z = 0
- while z < 360:
- y = math.cos(math.radians(z))*(hh/2-20)+(hh/2)
- z += incr
- waves[j].append(int(y))
- 0
- def store_wave(j):
- i = COMBOS.pop(0)
- COMBOS.append(i)
- PiXY(i,j)
- for z in range(many):
- store_wave(z)
- print
- zzz = 0
- root=Tk()
- canvas = Canvas(root,width=ww,height=hh,bg='black')
- canvas.grid(row=0,column=0,sticky=N+S+E+W)
- def high():
- L = len(waves)
- t = []
- for z in range(L):
- try:
- t += [waves[z].pop()]
- except:
- store_wave(z)
- t += [waves[z].pop()]
- return sum(t)/L
- 0
- def plot():
- color = oRGB(rgb)
- x = xx+2
- canvas.create_line((x, 0, x, yy), fill=color)
- 0
- def oRGB(rgb):
- r,g,b = rgb
- return "#%02x%02x%02x" % (r,g,b)
- 0
- while 1:
- canvas.delete('all')
- for xx in range(0,ww):
- rgb = 255,255,0 # yellow
- yy = high()
- plot()
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement