Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_wave_fn.py
- from tkinter import *
- from PIL import Image, ImageTk
- import random
- import math
- import time
- root = Tk()
- root.title("Wave Algorithm")
- wt = 1400
- ht = 100
- root.geometry("%dx%d+-10+0"%(wt,ht))
- canvas = Canvas(root, width=wt, height=ht)
- canvas.pack()
- def fn_wave():
- z = [zzz[(x//dist)*dist] for dist in [8,64,128,256]]
- z = (y*70+sum(z))/74
- return z
- img = Image.new('RGB', (wt,ht))
- zz = {}
- XYo = []
- c = 0
- for y in range(ht):
- for x in range(wt):
- zz[x,y] = c
- XYo.append((255,255,255))
- c += 1
- 0
- yy = 50
- y = 0.0
- while 1:
- xy = XYo[:]
- zzz = [random.randint(-50,50) for z in range(wt)]
- for x in range(wt):
- y = fn_wave()
- xy[zz[x,int(y+yy)]] = (0,0,255)
- img.putdata(tuple(xy))
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- canvas.update()
- time.sleep(0.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement