Advertisement
here2share

# Tk_seq_shuffle_8.py

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