Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_RGB_ani.py
- from tkinter import *
- from PIL import Image, ImageTk
- import random
- import math
- import time
- ww = 270
- hh = 270
- root = Tk()
- root.title("Tk RGB")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.grid()
- img = Image.new("RGB",(ww,hh), "white")
- cc = {}
- for x in range(ww):
- for y in range(hh):
- cc[x,y] = 0
- xy = []
- x2 = 256.0/ww
- y2 = 256.0/hh
- for y in range(hh):
- b = int(y*y2)
- for x in range(ww):
- a = int(x*x2)
- c = cc[a,b]
- xy += [(a,b,c)]
- cc[a,b] = c+1
- 0
- animate = list(map(list, xy))
- while 1:
- img.putdata(xy)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- root.update()
- xy = []
- for i,rgb in enumerate(animate):
- ttt = []
- for j,v in enumerate((7,9,11)):
- t = rgb[j]-v
- if t < -255:
- t = 255
- ttt += [abs(t)]
- animate[i][j] = t
- xy += [tuple(ttt)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement