Advertisement
here2share

# Tk_rgb_gradient.py

Jul 28th, 2020 (edited)
3,271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. # Tk_rgb_gradient.py ZZZ left-click-scroll
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6. import math
  7. import time
  8.  
  9. wt = 1400
  10. ht = 690
  11. root = Tk()
  12. root.title("Tk RGB")
  13. root.geometry("%dx%d+0+0"%(wt,ht))
  14. canvas = Canvas(root, width=wt, height=ht)
  15. canvas.grid()
  16.  
  17. img = Image.new("RGB",(wt,ht), "white")
  18.  
  19. cc = {}
  20. for x in range(wt):
  21.     for y in range(ht):
  22.         cc[x,y] = 0
  23.  
  24. xy = []
  25. x2 = 256.0/wt
  26. y2 = 256.0/ht
  27. for y in range(ht):
  28.     b = int(y*y2)
  29.     for x in range(wt):
  30.         a = int(x*x2)
  31.         c = cc[a,b]
  32.         xy += [(a,b,c)]
  33.         cc[a,b] = c+1
  34. 0
  35. if 1:
  36.     img.putdata(xy)
  37.     imgTk = ImageTk.PhotoImage(img)
  38.     canvas.create_image(0, 0, anchor=NW, image=imgTk)
  39.     root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement