Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_wave_qref.py
- from Tkinter import *
- import math
- import time
- tx = time.time
- ww = 1400
- hh = 510
- root = Tk()
- root.title("Simple Wave Plotting")
- root.geometry("%dx%d+-6+-2"%(ww,hh))
- cv = Canvas(width=ww, height=hh, bg='white')
- cv.pack()
- def draw():
- xy = [(x,y) for x,y in enumerate(Ys)]
- cv.create_line(xy, fill='red')
- cv.update()
- x = 0
- Ys = [-99999,-99999,-99999]
- ydict = {}
- for radius in range(3,hh/4,2):
- for r in range(radius,radius*4,4):
- t = ydict
- tYs = Ys[:]
- for angle in range(0,radius*4):
- at = hh-r-2
- theta = math.pi*angle/radius/2
- y = int(math.cos(theta)*r+at)
- if y < 1:
- t = ydict
- tYs = Ys[:]
- break
- tYs.append(y)
- try:
- t[(tYs[-3],tYs[-2])].add(tYs[-1])
- t[(hh-tYs[-3],hh-tYs[-2])].add(hh-tYs[-1])
- except:
- t[(tYs[-3],tYs[-2])] = set([tYs[-1]])
- t[(hh-tYs[-3],hh-tYs[-2])] = set([hh-tYs[-1]])
- x += 1
- ydict = t
- Ys = tYs[:]
- cv.delete('all')
- Ys = Ys[-ww:]
- draw()
- ydict = dict([(k, tuple(ydict[k])) for k in ydict])
- print ydict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement