Advertisement
here2share

# Tk_Red_Green_Blue_Yellow_Spectrum.py

Jan 15th, 2020
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. # Tk_Red_Green_Blue_Yellow_Spectrum.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6. import math
  7. import time
  8.  
  9. wt = 640
  10. ht = 640
  11. root = Tk()
  12. root.title("Tk Shade Pattern")
  13. root.geometry("%dx%d+0+0"%(wt,ht))
  14. canvas = Canvas(root, width=wt, height=ht)
  15. canvas.grid()
  16.  
  17. def d(z):
  18.     return int(z*(255/640.0))
  19.  
  20. # create new image
  21. img = Image.new("RGB",(wt,ht), "white")
  22.  
  23. xy = []
  24. for x in range(wt):
  25.     for y in range(ht):
  26.         dx = d(x)
  27.         dy = d(y)
  28.         t = 256-((dx%255)+(dy%255))
  29.         xy.append((dx, dy, max(0,t)))
  30.  
  31. img.putdata(xy)
  32. imgTk = ImageTk.PhotoImage(img)
  33. time.sleep(1)
  34. canvas.create_image(0, 0, anchor=NW, image=imgTk)
  35. root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement