Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Trippy_Radial.py
- from Tkinter import *
- from PIL import Image, ImageTk
- import random
- import math
- ww = 512
- hh = 512
- ww2 = ww/2
- hh2 = hh/2
- root = Tk()
- root.title("Tk Trippy Radial.py")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.grid()
- img = Image.new("RGB",(ww,hh))
- ttt = range(256)
- ttt = [0]+ttt[:-1]+ttt[::-1]
- tL = len(ttt)
- pix = []
- for y in range(hh):
- for x in range(ww):
- pix.append(0)
- 0
- rrr = {}
- for y in range(hh):
- for x in range(ww):
- z = int((abs(ww2-x)**2+abs(hh2-y)**2)**0.5)
- if x < ww2:
- t = 0
- if y > hh2:
- t = 2
- else:
- t = 1
- if y > hh2:
- t = 3
- try:
- rrr[z] += [(t,x,y)]
- except:
- rrr[z] = [(t,x,y)]
- 0
- b = 3
- k = 5
- d = 10
- qqq = len(rrr)-1
- while 1:
- tL = len(ttt)
- for z in range(qqq):
- v = 512*b/360.0
- rrr[z].sort()
- L = len(rrr[z])
- L2 = L/2
- r2 = rrr[z][L2:]
- rrr[z] = rrr[z][:L2]+r2[::-1]
- for p,x,y in rrr[z]:
- t = (math.degrees(math.atan2(256-x,256-y))+180)*v
- pix[x+y*hh] = ttt[int(t+math.sin(z*k)*d+z)%tL]
- k += 0.02
- d += 1
- print k
- img.putdata(pix)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(1, 1, anchor=NW, image=imgTk)
- root.update()
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement