Advertisement
here2share

# Tk_seq_shuffle_2.py

Apr 15th, 2022
1,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. # Tk_seq_shuffle_2.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. rainbow=[]
  27. def z(r,g,b):
  28.     rainbow.append((r,g,b))
  29. r,g,b=255,0,0
  30. for g in range(256):
  31.     z(r,g,b)
  32. for r in range(254, -1, -1):
  33.     z(r,g,b)
  34. for b in range(256):
  35.     z(r,g,b)
  36. for g in range(254, -1, -1):
  37.     z(r,g,b)
  38. for r in range(256):
  39.     z(r,g,b)
  40. for b in range(254, -1, -1):
  41.     z(r,g,b)
  42. L = len(rainbow)
  43.  
  44. i = 1
  45. rgb = [(0,0,0)]*(ww*hh)
  46.  
  47. while 1:
  48.     ttt = []
  49.     for x in range(ww):
  50.         i += 1
  51.         t = rainbow.pop(i%L)
  52.         ttt += [t]
  53.         rainbow += [t]
  54.     rgb.extend(ttt)
  55.     rgb = rgb[-ww*hh:]
  56.     draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement