Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_infinite_cavern.py
- import tkinter as tk
- import math
- import random
- from PIL import Image, ImageTk, ImageFilter, ImageGrab
- import ctypes
- ww = 600
- hh = 600
- cx, cy = ww//2, hh//2
- root = tk.Tk()
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = tk.Canvas(root, bg='white', width=ww, height=hh)
- canvas.pack()
- radius = 1.5
- rgb = [i for i in range(0, 256, 5)]
- colors = ['#{:02x}{:02x}{:02x}'.format(r,g,b) for r in rgb for g in rgb for b in rgb][40:-40]
- random.shuffle(colors)
- number_of_points = 12
- morph_steps = 400
- points = []
- def blob():
- points[:] = []
- for j in range(number_of_points):
- angle = 2 * math.pi * j / number_of_points
- r = radius * random.uniform(0.2, 1)
- a = angle * random.uniform(0.95, 1)
- x = cx + r * math.cos(a)
- y = cy + r * math.sin(a)
- points.append((x, y))
- # Zoom into the center of the screen
- i = 0
- scale = 1.02
- blur_img = Image.new('RGB', (ww, hh), "white")
- blur_img = blur_img.filter(ImageFilter.GaussianBlur(5))
- while True:
- canvas.scale('all', cx, cy, scale, scale)
- if not int(i) % 80:
- blob()
- color = colors.pop(0)
- canvas.create_polygon(points, smooth=True, fill=color, outline='')
- colors.insert(-(10-int(i%10)), color)
- i += scale
- i %= 999999999
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement