Advertisement
here2share

# Tk_rgb_sequences.py

Nov 25th, 2022
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. # Tk_rgb_sequences.py
  2.  
  3. from tkinter import *
  4. from PIL import Image, ImageTk
  5. import math
  6. from itertools import combinations
  7.  
  8. ww = 500
  9. hh = 500
  10.  
  11. sz = 10
  12.  
  13. root = Tk()
  14. root.geometry("%dx%d+0+0"%(ww,hh))
  15. canvas = Canvas(root, width=ww, height=hh)
  16. canvas.pack()
  17.  
  18.  
  19. t = range(0,256,5)
  20. TTT = []
  21. for r in t:
  22.     for g in t:
  23.         for b in t:
  24.             TTT += [(r, g, b)]
  25. # TTT.sort(key=sum)
  26. TTT = TTT[1:-1]+TTT[::-1]
  27. LLL = len(TTT)
  28.  
  29. xy = []
  30. for y in range(0,hh,sz):
  31.     for x in range(0,ww+1,sz):
  32.         xy += [(x,y)]
  33.  
  34. def make_rgb():
  35.     return '#%02X%02X%02X'%(r,g,b)
  36.  
  37. i = 0
  38. seq = 1 # sequences
  39. sub = 1
  40. while 1:
  41.     ttt = TTT[:]
  42.     L = LLL
  43.     seq += 1
  44.     sub = seq
  45.     print (seq)
  46.     canvas.delete('all')
  47.     for x,y in xy:
  48.         r,g,b = ttt.pop(sub%L)
  49.         L = L - 1
  50.         sub = sub + seq
  51.         canvas.create_rectangle((x, y, x-sz, y+sz), fill=make_rgb(), width=0)
  52.     canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement