Advertisement
here2share

# Tk_rgb_sequences_2.py

Nov 25th, 2022
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # Tk_rgb_sequences_2.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.  
  28.  
  29. def make_rgb():
  30.     return '#%02X%02X%02X'%(r,g,b)
  31.  
  32. i = 0
  33. seq = 1 # sequences
  34. sub = 1
  35. while 1:
  36.     ttt = TTT[:]
  37.     seq += 1
  38.     sub = seq
  39.     print (seq)
  40.     canvas.delete('all')
  41.     for y in range(0,hh,sz):
  42.         L = len(ttt)
  43.         for x in range(0,ww+1,sz):
  44.             r,g,b = ttt.pop(sub%L)
  45.             L = L - 1
  46.             sub = sub + int(L/100) + seq
  47.             canvas.create_rectangle((x, y, x-sz, y+sz), fill=make_rgb(), width=0)
  48.     canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement