Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Migrate_2.py
- from Tkinter import *
- from math import floor
- import time
- import random
- ri = random.randint
- rs = random.shuffle
- rc = random.choice
- tx = time.time
- ww = 600
- hh = 600
- root = Tk()
- root.title("Tk_Migrate_2")
- root.geometry("%dx%d+-6+-2"%(ww,hh))
- cv = Canvas(width=ww, height=hh, bg='black')
- cv.pack()
- r = 5
- r2 = 3
- ww = ww / r + 1
- hh = hh / r + 1
- def rgb2hex(r,g,b):
- return '#%02X%02X%02X'%(r,g,b)
- gradient = [rgb2hex(0,0,0) for z in range(50)]
- gradient += [rgb2hex(0,z,0) for z in range(0,256,4)]
- gradient = gradient[1:-1]+gradient[::-1]
- L = len(gradient)
- cv_grid = dict([((x, y), 0) for x in range(ww) for y in range(hh)])
- area = ','.join(['(x+'+str(x)+',y+'+str(y)+')' for x in range(10) for y in range(10)])
- area = eval('lambda x,y: ['+area+']')
- balance = bal = [(x, y) for x in range(-5,ww) for y in range(-5,hh)]
- def bloom(x, y):
- try:
- cv_grid[x, y] += 21
- zzz = [ [x + 1, y],
- [x + 1, y],
- [x, y + 1],
- [x, y - 1]]
- for a,b in zzz:
- cv_grid[a, b] = cv_grid[a, b] + (cv_grid[a, b] * 0.001)
- except:
- 0
- while 1:
- if not bal:
- bal = balance[:]
- rs(bal)
- x,y = bal.pop()
- xy = area(x,y)
- rs(xy)
- for x,y in xy:
- bloom(x, y)
- try:
- cv_grid[x, y] %= L
- xy = cv_grid[x, y]
- rgb = gradient[int(xy)]
- cv.create_oval((x*r-r2,y*r-r2,x*r+r2,y*r+r2),fill=rgb,outline='')
- cv.update()
- except:
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement