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 True:
- 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)
- Lc = len(RGBs)
- 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 oRGB(rgb):
- 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 range(5, 100)]
- zz = zz + zz[::-1]
- px, py = 1, 1
- while True:
- for xx in zz:
- py += 0.1
- yy = int(py)
- pix = []
- def cycle(x, y, xx, yy):
- 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
- for x in range(ww):
- for y in range(hh):
- pix.append(RGBs[cycle(x, y, xx, yy) % 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.img = imgTk # Prevent garbage collection
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment