Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_basic_math_art.py
- from Tkinter import *
- import random, time
- max = 1000
- ww = 200
- hh = 300
- root = Tk()
- root.title("Tk basic math art")
- root.geometry("%dx%d+0+0"%(ww,hh))
- sss = []
- COLORS = 'red orange yellow green blue purple'.split()
- fg = 'red orange blue purple black'.split()
- bg = 'yellow white gray90'.split()
- def rgb2hex(r,g,b):
- return '#%02X%02X%02X'%(r,g,b)
- def draw():
- canvas.delete()
- colors = [random.choice(z) for z in (fg,bg)]
- L = 2
- t = c
- clock = time.time()
- for y in range(hh):
- for x in range(ww):
- t = (x+y+t)%(9+int(c+x/20.0))
- canvas.create_rectangle((x,y,x,y), fill=colors[t%L], outline='')
- print time.time()-clock
- canvas.update()
- 0
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- c = 1
- while 1:
- c += 1
- draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement