here2share

# Tk_seq_shuffle_4.py

Apr 16th, 2022 (edited)
526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. # Tk_seq_shuffle_4.py
  2.  
  3. from tkinter import *
  4. from PIL import Image, ImageTk
  5. from itertools import combinations
  6.  
  7. ww = 600
  8. hh = 600
  9.  
  10. def draw():
  11.     image.putdata(rgb)
  12.     photo = ImageTk.PhotoImage(image)
  13.     canvas.create_image(0,0,image=photo,anchor=NW)
  14.     canvas.update()
  15.    
  16.  
  17. root = Tk()
  18. root.title("Tk_seq_shuffle")
  19. root.geometry("%dx%d+0+0"%(ww,hh))
  20.    
  21. canvas = Canvas(root, width=ww, height=hh)
  22. canvas.pack()
  23.  
  24. image = Image.new("RGB", (ww,hh), (255,255,255))
  25.  
  26. COLORS = [(255,0,0),(0,0,255),(255,255,0)]
  27. colors = [(255,0,0),(0,0,255),(255,255,0)]*10000
  28. L = len(colors)
  29.  
  30. i = 1
  31. rgb = [(0,0,0)]*(ww*hh)
  32.  
  33. j = dict([(colors[i],1) for i in (0,1,2)])
  34. y_switch = dict([(i,j) for i in range(ww)])
  35. # print (y_switch)
  36. color = {}
  37.  
  38. while 1:
  39.     ttt = []
  40.     for x in range(ww):
  41.         i += 1
  42.         t = colors.pop(i%L)
  43.         y_switch[x][t] -= 1
  44.         if y_switch[x][t] < 1:
  45.             y_switch[x] = dict([(COLORS[i],15) for i in (0,1,2)])
  46.             y_switch[x][t] += 5
  47.             color[x] = t
  48.         ttt += [color[x]]
  49.         colors += [t]
  50.     rgb.extend(ttt)
  51.     rgb = rgb[-ww*hh:]
  52.     draw()
Add Comment
Please, Sign In to add comment