# tk_pulsate_zoom.py import tkinter as tk from PIL import Image, ImageTk import random WW, HH = 640, 640 scale = 20 blend_alpha = 0.025 # Subtle blend effect root = tk.Tk() root.title("# tk_pulsate_zoom.py") canvas = tk.Canvas(root, width=WW, height=HH) canvas.pack() grid_colors = { (0, 0): (255, 255, 255), (0, 1): (255, 255, 0), (0, 2): (0, 255, 0), (1, 0): (255, 165, 0), (1, 1): (128, 128, 128), (1, 2): (0, 0, 255), (2, 0): (255, 0, 0), (2, 1): (128, 0, 128), (2, 2): (0, 0, 0) } small_img = Image.new('RGB', (3, 3)) for y in range(3): for x in range(3): small_img.putpixel((x, y), grid_colors[(x, y)]) base_img = small_img.resize((WW, HH)) shuffle_img = small_img.resize((7, 7)) data = list(shuffle_img.getdata()) def shuffled_image(): random.shuffle(data) small_shuffled = Image.new('RGB', (7, 7)) small_shuffled.putdata(data) return small_shuffled.resize((WW, HH)) img = base_img.copy() photo = ImageTk.PhotoImage(img) shuffled_img = Image.new('RGB', img.size) canvas.create_image(0, 0, image=photo, anchor=tk.NW) i = 0 while True: zoomed = img.resize((WW, HH)) photo = ImageTk.PhotoImage(zoomed) canvas.create_image(0, 0, image=photo, anchor=tk.NW) img = img.crop((scale, scale, WW - scale, HH - scale)) img = img.resize((WW, HH)) i += 1 if i > 10: shuffled_img = shuffled_image() i = 0 img = Image.blend(img, shuffled_img, alpha=blend_alpha) root.update()