Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_radial_gradients_spin.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 Radial Gradients Spin.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 = 5
- qqq = len(rrr)-1
- spiral = 0
- while 1:
- v = 512*b/360.0
- for z in range(qqq):
- rrr[z].sort()
- L = len(rrr[z])
- L2 = L/2
- r2 = rrr[z][L2:]
- rrr[z] = rrr[z][:L2]+r2[::-1]
- spiral += 1.2
- for p,x,y in rrr[z]:
- p = (math.degrees(math.atan2(256-x,256-y))+180)*v
- pix[x+y*hh] = ttt[int(p+spiral)%tL]
- print b
- img.putdata(pix)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(1, 1, anchor=NW, image=imgTk)
- root.update()
- 0
Add Comment
Please, Sign In to add comment