Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Gradient_Scatter.py
- from Tkinter import *
- from PIL import Image, ImageTk
- import random
- import math
- import time
- ww = 640
- hh = 640
- root = Tk()
- root.title("Tk Gradient Scatter")
- 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)
- img = Image.new("RGB",(ww,hh), "white")
- while 1:
- pix = []
- inc = 0.002
- yoff = 0
- for x in range(ww):
- xoff = 0
- for y in range(hh):
- rgb = int(random.uniform(xoff, yoff)*Lc)
- # rgb = int((xoff+yoff)/2*Lc)
- pix.append(RGBs[rgb%Lc])
- xoff += inc
- yoff += inc
- img.putdata(pix)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement