Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_2D_Waves_Of_Four.py
- from itertools import permutations
- L = range(0,255,10)
- L[-1] = 255
- combos = [z for z in permutations(L, 4)]
- from PIL import Image, ImageTk, ImageDraw
- from Tkinter import *
- import PIL
- import math
- ww = 400
- hh = 400
- waves = {}
- ppp = list('abcd')
- for i in (69,180,123,299):
- incr = (360.0/i)
- xy = {}
- p = ppp.pop()
- waves[p] = []
- z = 0
- while z < 360:
- s = math.cos(math.radians(z))*(hh/2-20)+(hh/2)
- xy[len(xy)] = min(600,int(s))
- z += incr
- t = [xy[z] for z in range(len(xy))]
- waves[p].extend(t)
- 0
- a,b,c,d = waves
- a2 = len(waves[a])
- b2 = len(waves[b])
- c2 = len(waves[c])
- d2 = len(waves[d])
- 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():
- aa = waves[a][zzz%a2]
- bb = waves[b][zzz%b2]
- cc = waves[c][zzz%c2]
- dd = waves[d][zzz%d2]
- return (aa+bb+cc+dd)/4
- 0
- wide = []
- while zzz != ww+2:
- wide.append(high())
- zzz += 1
- 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):
- yy = wide[xx]
- rgb = 255,255,0
- plot()
- canvas.update()
- wide.append(high())
- wide.pop(0)
- zzz += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement