Advertisement
here2share

# Tk_rgb_brush_putdata.py

Apr 4th, 2022
1,201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # Tk_rgb_brush_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_rgb_brush_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", (ww,hh), (255,255,255))
  28. scan = [tuple([random.randint(0,255) for z in 'rgb']) for z in range(ww)]
  29.  
  30. while 1:
  31.     rgb = []
  32.     for y in range(hh):
  33.         ttt = []
  34.         for data in scan:
  35.             t = tuple([(i+random.choice((-15,0,15)))%255 for i in data])
  36.             ttt.append(t)
  37.             rgb.append(t)
  38.         scan = ttt[:]
  39.     draw()
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement