Advertisement
here2share

# Tk_crayon_putdata.py

Sep 26th, 2021
1,267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. # Tk_crayon_putdata.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6. from itertools import permutations
  7.  
  8. ww = 600
  9. hh = 600
  10. root = Tk()
  11. root.title("Tk_crayon_putdata.py")
  12. root.geometry("%dx%d+0+0"%(ww,hh))
  13.  
  14. def rgb2hex(r,g,b):
  15.     return '#%02X%02X%02X'%(r,g,b)
  16.  
  17. def draw():
  18.     image.putdata(rgb)
  19.     photo = ImageTk.PhotoImage(image)
  20.     canvas.create_image(0,0,image=photo,anchor=NW)
  21.     canvas.update()
  22. 0
  23.  
  24. canvas = Canvas(root, width=ww, height=hh)
  25. canvas.pack()
  26.  
  27. image = Image.new("RGB", (600,600), (255,255,255))
  28. scan = [[tuple([random.randint(0,ww) for z in 'rgb']),random.randint(0,ww)] for z in range(int(ww*2))]
  29.  
  30. ttt = [(255,255,255)]*ww
  31. while 1:
  32.     rgb = []
  33.     for y in range(hh):
  34.         t = ttt[:]
  35.         for z,data in enumerate(scan):
  36.             color,x = data
  37.             scan[z][1] = (x+random.choice((-1,0,1)))%ww #
  38.             try:
  39.                 t[x] = color
  40.             except:
  41.                 0
  42.         rgb.extend(t)
  43.     draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement