# tk_Organic_Ripple_Cache.py
import tkinter as tk
import math
import random
from PIL import Image, ImageTk, ImageDraw, ImageFilter
WIDTH, HEIGHT = 640, 480
CENTER_X, CENTER_Y = WIDTH // 2, HEIGHT // 2
root = tk.Tk()
root.title("# tk_Organic_Ripple_Cache.py")
canvas = tk.Canvas(root, width=WIDTH, height=HEIGHT, bg="black")
canvas.pack()
img_label = canvas.create_image(0, 0, anchor=tk.NW)
img = Image.new('RGB', (WIDTH, HEIGHT), (0, 0, 64))
particles = []
num_ripples = 6
points_per_ripple = 50
for ripple_idx in range(num_ripples):
start_dist = ripple_idx * 70
for i in range(points_per_ripple):
angle = (i / points_per_ripple) * 2 * math.pi
angle_offset = random.uniform(-0.05, 0.05)
particles.append({
'angle': angle + angle_offset,
'dist': start_dist,
'speed': 1.8,
'ripple_idx': ripple_idx,
'dx': random.uniform(-5, 5),
'dy': random.uniform(-5, 5)
})
t = 0
intensity = 0.9
while True:
img.paste((0, 0, 64), [0, 0, WIDTH, HEIGHT])
t += 0.05
draw = ImageDraw.Draw(img)
for p in particles:
p['dist'] += p['speed']
if p['dist'] > 425:
p['dist'] = 0
p['dx'] = random.uniform(-12, 12)
p['dy'] = random.uniform(-12, 12)
wobble = math.sin(t * 5 + p['angle'] * 5) * 4.2
x = CENTER_X + math.cos(p['angle']) * (p['dist'] + wobble) + p['dx']
y = CENTER_Y + math.sin(p['angle']) * (p['dist'] + wobble) + p['dy']
wave = math.sin(p['dist'] * 0.2 - t * 2) * 0.3 + 0.7
size = 9
draw.ellipse([x - size, y - size, x + size, y + size],
fill=(210, 210, 210))
blurred_img = img.filter(ImageFilter.GaussianBlur(radius=10))
photo = ImageTk.PhotoImage(blurred_img)
canvas.itemconfig(img_label, image=photo)
root.update_idletasks()
root.update()