Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_trinary_art_attempt.py
- from Tkinter import *
- import random, time
- from itertools import permutations
- ww = 200
- hh = 300
- root = Tk()
- root.title("Tk_trinary_art_attempt")
- root.geometry("%dx%d+0+0"%(ww,hh))
- def rgb2hex(r,g,b):
- return '#%02X%02X%02X'%(r,g,b)
- def draw():
- canvas.delete()
- for y in range(hh):
- for x in move:
- x = x+y%6
- t = tuple(scan[x:x+3])
- try:
- t = magic[t]
- scan[x:x+3] = t
- except:
- scan[x],scan[0] = scan[0],scan[x]
- for x in range(6,Lscan-6):
- t = scan[x]
- canvas.create_rectangle((x-6,y,x-6,y), fill=COLORS[t%Lcolors], outline='')
- canvas.update()
- 0
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- COLORS = 'red orange yellow green blue purple'.split()
- Lcolors = len(COLORS)
- magic = list(permutations(range(Lcolors), 3))
- scan = range(Lcolors)*(ww/Lcolors+20)
- Lscan = len(scan)
- move = range(0,Lscan,6)
- while 1:
- magic = [((a,b,c),random.choice(((a,b,c),(a,c,b),(b,a,c),(b,c,a),(c,a,b),(c,b,a)))) for a,b,c in magic]
- magic = dict(magic)
- random.shuffle(move)
- random.shuffle(scan)
- draw()
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement