Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_img_combos.py
- import tkinter as tk
- from PIL import Image, ImageTk, ImageFilter
- root = tk.Tk()
- root.geometry("600x600+0+0")
- image_label = tk.Label(root)
- image_label.pack()
- image = Image.new("RGB", (600, 600))
- def rotate(lst, n):
- return lst[n:] + lst[:n]
- combo = []
- loop = (0, 95, 190, 255)
- for b in loop:
- for g in loop:
- for r in loop:
- combo.append(tuple(v for v in (r, g, b)))
- i = len(combo) - 2
- while len(combo) > 36:
- if i % 5 == 0:
- combo.pop(i)
- i = i - 1
- if i == 0:
- i = len(combo) - 2
- L = len(combo) - 2
- first_combo = combo[:]
- rotation_index = 0
- while True:
- i = 0
- for y in range(6):
- for x in range(6):
- color = combo[i]
- i += 1
- image.paste(Image.new("RGB", (100, 100), color), (x * 100, y * 100))
- combo = rotate(combo, rotation_index)
- combo.append(combo.pop(rotation_index))
- img = image.filter(ImageFilter.GaussianBlur(radius=50))
- photo_image = ImageTk.PhotoImage(img)
- image_label.configure(image=photo_image)
- root.update()
- if rotation_index and combo == first_combo:
- break
- rotation_index = max(1, (rotation_index + 1) % L)
Advertisement
Add Comment
Please, Sign In to add comment