here2share

# tk_Organic_Ripple_Cache.py

Oct 7th, 2025
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.92 KB | None | 0 0
  1. # tk_Organic_Ripple_Cache.py
  2.  
  3. import tkinter as tk
  4. import math
  5. import random
  6. from PIL import Image, ImageTk, ImageDraw, ImageFilter
  7.  
  8. WIDTH, HEIGHT = 640, 480
  9. CENTER_X, CENTER_Y = WIDTH // 2, HEIGHT // 2
  10. root = tk.Tk()
  11. root.title("# tk_Organic_Ripple_Cache.py")
  12. canvas = tk.Canvas(root, width=WIDTH, height=HEIGHT, bg="black")
  13. canvas.pack()
  14. img_label = canvas.create_image(0, 0, anchor=tk.NW)
  15.  
  16. img = Image.new('RGB', (WIDTH, HEIGHT), (0, 0, 64))
  17.  
  18. particles = []
  19. num_ripples = 6
  20. points_per_ripple = 50
  21.  
  22. for ripple_idx in range(num_ripples):
  23.     start_dist = ripple_idx * 70
  24.     for i in range(points_per_ripple):
  25.         angle = (i / points_per_ripple) * 2 * math.pi
  26.         angle_offset = random.uniform(-0.05, 0.05)
  27.         particles.append({
  28.             'angle': angle + angle_offset,
  29.             'dist': start_dist,
  30.             'speed': 1.8,
  31.             'ripple_idx': ripple_idx,
  32.             'dx': random.uniform(-5, 5),
  33.             'dy': random.uniform(-5, 5)
  34.         })
  35.  
  36. t = 0
  37. intensity = 0.9
  38. while True:
  39.     img.paste((0, 0, 64), [0, 0, WIDTH, HEIGHT])
  40.     t += 0.05
  41.  
  42.     draw = ImageDraw.Draw(img)
  43.  
  44.     for p in particles:
  45.         p['dist'] += p['speed']
  46.         if p['dist'] > 425:
  47.             p['dist'] = 0
  48.             p['dx'] = random.uniform(-12, 12)
  49.             p['dy'] = random.uniform(-12, 12)
  50.  
  51.         wobble = math.sin(t * 5 + p['angle'] * 5) * 4.2
  52.         x = CENTER_X + math.cos(p['angle']) * (p['dist'] + wobble) + p['dx']
  53.         y = CENTER_Y + math.sin(p['angle']) * (p['dist'] + wobble) + p['dy']
  54.  
  55.         wave = math.sin(p['dist'] * 0.2 - t * 2) * 0.3 + 0.7
  56.  
  57.         size = 9
  58.         draw.ellipse([x - size, y - size, x + size, y + size],
  59.                      fill=(210, 210, 210))
  60.  
  61.     blurred_img = img.filter(ImageFilter.GaussianBlur(radius=10))
  62.     photo = ImageTk.PhotoImage(blurred_img)
  63.     canvas.itemconfig(img_label, image=photo)
  64.     root.update_idletasks()
  65.     root.update()
Advertisement
Add Comment
Please, Sign In to add comment