here2share

# tk_img_combos.py

Sep 3rd, 2025
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. # tk_img_combos.py
  2.  
  3. import tkinter as tk
  4. from PIL import Image, ImageTk, ImageFilter
  5.  
  6. root = tk.Tk()
  7. root.geometry("600x600+0+0")
  8. image_label = tk.Label(root)
  9. image_label.pack()
  10.  
  11. image = Image.new("RGB", (600, 600))
  12.  
  13. def rotate(lst, n):
  14.     return lst[n:] + lst[:n]
  15.  
  16. combo = []
  17. loop = (0, 95, 190, 255)
  18. for b in loop:
  19.     for g in loop:
  20.         for r in loop:
  21.             combo.append(tuple(v for v in (r, g, b)))
  22.  
  23. i = len(combo) - 2
  24. while len(combo) > 36:
  25.     if i % 5 == 0:
  26.         combo.pop(i)
  27.     i = i - 1
  28.     if i == 0:
  29.         i = len(combo) - 2
  30. L = len(combo) - 2
  31. first_combo = combo[:]
  32.  
  33. rotation_index = 0
  34. while True:
  35.     i = 0
  36.     for y in range(6):
  37.         for x in range(6):
  38.             color = combo[i]
  39.             i += 1
  40.             image.paste(Image.new("RGB", (100, 100), color), (x * 100, y * 100))
  41.            
  42.     combo = rotate(combo, rotation_index)
  43.     combo.append(combo.pop(rotation_index))
  44.  
  45.     img = image.filter(ImageFilter.GaussianBlur(radius=50))
  46.  
  47.     photo_image = ImageTk.PhotoImage(img)
  48.     image_label.configure(image=photo_image)
  49.  
  50.     root.update()
  51.    
  52.     if rotation_index and combo == first_combo:
  53.         break
  54.    
  55.     rotation_index = max(1, (rotation_index + 1) % L)
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment