Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_plasma_attack.py
- from Tkinter import *
- from PIL import Image, ImageTk
- import math
- import colorsys
- z = 0
- RGBs = []
- while 1:
- z = z + 0.0007
- t = colorsys.hsv_to_rgb(z, 1, 1)
- t = tuple([int(round(c * 255.0)) for c in t])
- if t in RGBs:
- break
- else:
- RGBs.append(t)
- 0
- Lc = len(RGBs)
- print Lc
- z = 0
- angles = 2000
- incr = 360.0/angles
- xy = {}
- while z < 360:
- s = math.cos(math.radians(z))*10000
- xy[len(xy)] = max(-9999,min(9999,int(s)))
- z += incr
- waves = [xy[z] for z in range(len(xy))]
- Lw = len(waves)
- def w(z):
- return waves[z%Lw]
- def cycle():
- return sum([waves[z%angles] for z in (w(x+yy)-w(y-yy),w((xx+yy)*3)/2-w(y-x+xx))])/20+y*7
- 0
- def oRGB(rgb): # pass
- r,g,b = rgb
- return "#%02x%02x%02x" % (r,g,b)
- ww = 200
- hh = 200
- root = Tk()
- root.title("Tk_plasma_attack")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.grid()
- img = Image.new("RGB",(ww, hh))
- zz = [z for z in xrange(5,100)]
- zz = zz+zz[::-1]
- px,py = 1,1
- while 1:
- for xx in zz:
- py += 0.1
- yy = int(py)
- pix = []
- for x in range (ww):
- for y in range(hh):
- pix.append(RGBs[cycle()%Lc])
- id = ':'.join([str(int(z)) for z in (px,py)])
- px = xx
- print('Plasma Image '+id)
- img.putdata(pix)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- canvas.update()
Add Comment
Please, Sign In to add comment