Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Red_Green_Blue_Yellow_Spectrum.py
- from Tkinter import *
- from PIL import Image, ImageTk
- import random
- import math
- import time
- wt = 640
- ht = 640
- root = Tk()
- root.title("Tk Shade Pattern")
- root.geometry("%dx%d+0+0"%(wt,ht))
- canvas = Canvas(root, width=wt, height=ht)
- canvas.grid()
- def d(z):
- return int(z*(255/640.0))
- # create new image
- img = Image.new("RGB",(wt,ht), "white")
- xy = []
- for x in range(wt):
- for y in range(ht):
- dx = d(x)
- dy = d(y)
- t = 256-((dx%255)+(dy%255))
- xy.append((dx, dy, max(0,t)))
- img.putdata(xy)
- imgTk = ImageTk.PhotoImage(img)
- time.sleep(1)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement