Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Pattern_Search.py -- experimenting
- from Tkinter import *
- from PIL import Image, ImageTk
- import random
- import math
- import time
- ww = 640
- hh = 640
- root = Tk()
- root.title("Tk Pattern Search")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.grid()
- RGBs = []
- def z():
- RGBs.append((r,g,b))
- r,g,b = 255,0,0
- for g in range(256):
- z()
- for r in range(254, -1, -1):
- z()
- for b in range(256):
- z()
- for g in range(254, -1, -1):
- z()
- for r in range(256):
- z()
- for b in range(254, -1, -1):
- z()
- Lc = len(RGBs)
- t = (ww*hh)/Lc+1
- gradient = []
- for z in RGBs:
- gradient.extend([z]*t)
- gradient = gradient[:ww*hh]
- img = Image.new("RGB",(ww,hh), "white")
- ttt = 1
- while 1:
- pix = []
- t = 0
- for x in range(ww):
- for y in range(hh):
- pix.append((x+t%ttt))
- t += 1
- pix = [x for y, x in sorted(zip(pix, gradient))]
- img.putdata(pix)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- root.update()
- print ttt
- ttt += 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement