Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_spiral_gen.py ZZZ so close...
- 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 Spiral Generator.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 = ttt[1:-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 = 1
- t = 400.0
- qqq = len(rrr)-1
- while 1:
- for z in range(qqq):
- rrr[z].sort()
- L = len(rrr[z])
- L2 = L/2
- r2 = rrr[z][L2+1:]
- rrr[z] = rrr[z][:L2+1]+r2[::-1]
- L = t/L
- for p,x,y in rrr[z]:
- pix[x+y*hh] = ttt[int(b)%tL]
- b += L
- print t
- t += 1
- 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