Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_crayon_putdata.py
- from Tkinter import *
- from PIL import Image, ImageTk
- import random
- from itertools import permutations
- ww = 600
- hh = 600
- root = Tk()
- root.title("Tk_crayon_putdata.py")
- root.geometry("%dx%d+0+0"%(ww,hh))
- def rgb2hex(r,g,b):
- return '#%02X%02X%02X'%(r,g,b)
- def draw():
- image.putdata(rgb)
- photo = ImageTk.PhotoImage(image)
- canvas.create_image(0,0,image=photo,anchor=NW)
- canvas.update()
- 0
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- image = Image.new("RGB", (600,600), (255,255,255))
- scan = [[tuple([random.randint(0,ww) for z in 'rgb']),random.randint(0,ww)] for z in range(int(ww*2))]
- ttt = [(255,255,255)]*ww
- while 1:
- rgb = []
- for y in range(hh):
- t = ttt[:]
- for z,data in enumerate(scan):
- color,x = data
- scan[z][1] = (x+random.choice((-1,0,1)))%ww #
- try:
- t[x] = color
- except:
- 0
- rgb.extend(t)
- draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement