Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_duo_wave.py
- from PIL import Image, ImageTk, ImageDraw
- from Tkinter import *
- import PIL
- import math
- ww = 1000
- hh = 400
- waves = {}
- ppp = list('ab')
- for i in (97,120):
- 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 = waves
- a2 = len(waves[a])
- b2 = len(waves[b])
- c = 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][c%a2]
- bb = waves[b][c%b2]
- return (aa+bb)/2
- 0
- wide = []
- while c != ww+2:
- wide.append(high())
- c += 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)
- c += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement