Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_RGB_plasma.py
- from tkinter import *
- from PIL import Image, ImageTk
- from math import sin, pi, radians, degrees
- ww = 270
- hh = 270
- root = Tk()
- root.title("Tk_RGB_plasma")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.grid()
- img = Image.new("RGB",(ww,hh), "white")
- cc = {}
- for x in range(ww):
- for y in range(hh):
- cc[x,y] = 0
- xy = []
- x2 = 256.0/ww
- y2 = 256.0/hh
- for y in range(hh):
- b = int(y*y2)
- for x in range(ww):
- a = int(x*x2)
- c = cc[a,b]
- xy += [(a,b,c)]
- cc[a,b] = c+1
- zz = xy[:]
- o255 = [z for z in range(256)]
- o255 = o255[1:-1] + o255[::-1]
- Lo = len(o255)
- fade = [z for z in range(30)]
- fade = fade[1:-1] + fade[::-1]
- Lx = len(fade)
- Lz = range(ww*hh)
- def draw():
- img.putdata(xy)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- root.update()
- t = 1
- while 1: # to keep looping
- draw()
- ttt = []
- for i in Lz:
- rgb = []
- for j in (0,1,2):
- rgb += [(zz[i][j] + t + ((j + 1) * 1.001)) % Lo]
- r,g,b = rgb
- chk = o255[int(r)%Lo], o255[int(g)%Lo], o255[int(b)%Lo]
- xy[i] = chk
- zz[i] = rgb
- t += 0.01
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement