Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_Piranha_Frenzy.py
- import tkinter as tk
- from PIL import Image, ImageTk, ImageFilter, ImageOps, ImageDraw
- import math
- import time
- import random
- ww = 600
- hh = 600
- root = tk.Tk()
- root.title("tk Piranha Frenzy")
- canvas = tk.Canvas(root, width=ww+300, height=hh)
- canvas.pack()
- def create_layers():
- img = Image.new("L", (ww+200, hh+200))
- dr = ImageDraw.Draw(img)
- dr.rectangle(((0, 0), (ww+200, (hh+200) * 0.80)), fill='white')
- pixels = list(img.getdata())
- random.shuffle(pixels)
- img.putdata(pixels)
- return img
- image_A = create_layers()
- image_B = create_layers()
- while 1:
- image_A = image_A.filter(ImageFilter.BLUR)
- image_B = image_B.filter(ImageFilter.BLUR)
- image_A = image_A.point(lambda i: (i + 1) % 255)
- image_B = image_B.point(lambda i: (i + 1) % 254)
- image = Image.blend(image_A, image_B, 0.5)
- left = 100
- top = 100
- right = ww + 100
- bottom = hh + 100
- image = image.crop((left, top, right, bottom))
- photo = ImageTk.PhotoImage(image)
- canvas.create_image(0, 0, image=photo, anchor=tk.NW)
- root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement