Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_Animate_Tunnel.py
- from tkinter import *
- from PIL import Image, ImageTk
- import random
- import math
- import time
- def rgb2hex(rgb):
- r,g,b = [int(max(0,z)) for z in rgb]
- return "#{:02x}{:02x}{:02x}".format(r,g,b)
- ww = 680
- hh = 680
- root = Tk()
- root.title("Tk Animate Tunnel")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh, bg=rgb2hex((200,200,255)))
- canvas.grid()
- def square(Ymin,Xmin,v,cl):
- color = rgb2hex((cl/1.5,cl/1.5,cl))
- sq = [int(z)+ww/2+10 for z in (Xmin-v,Ymin-v,Xmin+v,Ymin+v)]
- canvas.create_rectangle(sq,fill=color,outline=color)
- c = 0
- while 1:
- canvas.delete(ALL)
- delay = time.time()+0.1
- cm = 255
- a = range(370,10,-30)
- d = len(a)
- for n in a :
- z = math.sin(c)*10
- z1 = math.cos(c*0.995)*10
- square(0.5-z1,0.5-d+z+z1,n*0.80, cm)
- c += 1
- cm -= 15
- while delay > time.time():
- 0
- root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement