Advertisement
here2share

# Tk_1400x700_Gradient.py

Apr 18th, 2020 (edited)
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # Tk_1400x700_Gradient.py
  2.  
  3. from tkinter import *
  4. from PIL import Image, ImageTk
  5.  
  6. root = Tk()
  7. root.title("1400x700 Gradient")
  8. wt = 1400
  9. ht = 700
  10. root.geometry("%dx%d+-10+0"%(wt,ht))
  11. canvas = Canvas(root, width=wt, height=ht)
  12. canvas.pack()
  13.  
  14. print("this should take less than a minute to process...")
  15. D = 20
  16. t = [z for z in range(256)]
  17. a = {}
  18. for z in t:
  19.     v = min(z,256-D)
  20.     a[z] = range(v,v+D)
  21. p = {}
  22. def gen(w,h):
  23.     w2 = w/255.0
  24.     h2 = h/255.0
  25.     for y in range(h):
  26.         cy = int(y/h2)
  27.         for x in range(w):
  28.             cx = int(x/w2)
  29.             r = 255-cx
  30.             g = 255-cy
  31.             b = (cx+cy)//2
  32.             for bbb in a[b]:
  33.                 z = (r,g,bbb)
  34.                 try:
  35.                     p[z]
  36.                 except:
  37.                     break
  38.             rgb.append(z)
  39.             p[z] = 1
  40. 0
  41. if 1:
  42.     rgb = []
  43.     gen(wt,ht)
  44.     img = Image.new('RGB', (wt,ht))
  45.     img.putdata(rgb)
  46.     imgTk = ImageTk.PhotoImage(img)
  47.     canvas.create_image(0, 0, anchor=NW, image=imgTk)
  48.     root.update()
  49. 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement