Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_rgb_transition.py
- from tkinter import *
- import time
- from PIL import Image, ImageTk
- from random import shuffle as rs, randint as ri
- tx = time.time
- ww = 600
- hh = 600
- root = Tk()
- root.title("Tk_rgb_transition")
- root.geometry("%dx%d+-6+-2"%(ww,hh))
- canvas = Canvas(width=ww, height=hh)
- canvas.pack()
- def motion(event):
- mouse_pos.append((event.x, event.y))
- root.bind('<B1-Motion>', motion)
- rgb = []
- screen = []
- xy = {}
- w = 255.0/ww
- h = 255.0/hh
- ttt = [i for i in range(0,255)]
- ttt = ttt[:-1]+ttt[::-1]
- ttt.pop()
- L = len(ttt)
- for j in range(0,hh):
- for i in range(0,ww):
- xy[i,j] = len(rgb)
- rgb += [(int(j*h),int(i*w),min(i,j))]
- screen += [(i,j)]
- rgb_float = rgb[:]
- mouse_pos = []
- image = Image.new("RGB", (ww,hh))
- def draw():
- image.putdata(rgb)
- photo = ImageTk.PhotoImage(image)
- canvas.create_image(0,0,image=photo,anchor=NW)
- canvas.update()
- incr = [round(i*0.01,2) for i in range(1,101)]
- incr = incr[:-1]+incr[::-1]
- incr.pop()
- incr2 = incr[:]
- transition = range(3,70000,111)
- L2 = len(transition)
- while 1:
- # rs(screen)
- for i,j in screen:
- t = xy[i,j]
- pa = []
- pb = []
- for k,v in enumerate(rgb_float[t]):
- v2 = transition[(t**(k*3+7))%L2]
- p = (v+v2)%L
- pa += [p]
- pb += [ttt[int(p)%L]]
- rgb_float[t] = pa
- rgb[t] = tuple(pb)
- draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement