Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_seq_shuffle_4.py
- from tkinter import *
- from PIL import Image, ImageTk
- from itertools import combinations
- ww = 600
- hh = 600
- def draw():
- image.putdata(rgb)
- photo = ImageTk.PhotoImage(image)
- canvas.create_image(0,0,image=photo,anchor=NW)
- canvas.update()
- root = Tk()
- root.title("Tk_seq_shuffle")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- image = Image.new("RGB", (ww,hh), (255,255,255))
- COLORS = [(255,0,0),(0,0,255),(255,255,0)]
- colors = [(255,0,0),(0,0,255),(255,255,0)]*10000
- L = len(colors)
- i = 1
- rgb = [(0,0,0)]*(ww*hh)
- j = dict([(colors[i],1) for i in (0,1,2)])
- y_switch = dict([(i,j) for i in range(ww)])
- # print (y_switch)
- color = {}
- while 1:
- ttt = []
- for x in range(ww):
- i += 1
- t = colors.pop(i%L)
- y_switch[x][t] -= 1
- if y_switch[x][t] < 1:
- y_switch[x] = dict([(COLORS[i],15) for i in (0,1,2)])
- y_switch[x][t] += 5
- color[x] = t
- ttt += [color[x]]
- colors += [t]
- rgb.extend(ttt)
- rgb = rgb[-ww*hh:]
- draw()
Add Comment
Please, Sign In to add comment