here2share

# Tk_plasma_attack.py

May 11th, 2020
2,504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. # Tk_plasma_attack.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import math
  6. import colorsys
  7.  
  8. z = 0
  9. RGBs = []
  10. while 1:
  11.     z = z + 0.0007
  12.     t = colorsys.hsv_to_rgb(z, 1, 1)
  13.     t = tuple([int(round(c * 255.0)) for c in t])
  14.     if t in RGBs:
  15.         break
  16.     else:
  17.         RGBs.append(t)
  18. 0
  19. Lc = len(RGBs)
  20. print Lc
  21.  
  22. z = 0
  23. angles = 2000
  24. incr = 360.0/angles
  25. xy = {}
  26. while z < 360:
  27.     s = math.cos(math.radians(z))*10000
  28.     xy[len(xy)] = max(-9999,min(9999,int(s)))
  29.     z += incr
  30. waves = [xy[z] for z in range(len(xy))]
  31. Lw = len(waves)
  32.  
  33. def w(z):
  34.     return waves[z%Lw]
  35.  
  36. def cycle():
  37.     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
  38. 0
  39. def oRGB(rgb): # pass
  40.     r,g,b = rgb
  41.     return "#%02x%02x%02x" % (r,g,b)
  42.  
  43. ww = 200
  44. hh = 200
  45. root = Tk()
  46. root.title("Tk_plasma_attack")
  47. root.geometry("%dx%d+0+0"%(ww,hh))
  48. canvas = Canvas(root, width=ww, height=hh)
  49. canvas.grid()
  50.  
  51. img = Image.new("RGB",(ww, hh))
  52.  
  53. zz = [z for z in xrange(5,100)]
  54. zz = zz+zz[::-1]
  55. px,py = 1,1
  56. while 1:
  57.     for xx in zz:
  58.         py += 0.1
  59.         yy = int(py)
  60.         pix = []
  61.         for x in range (ww):
  62.             for y in range(hh):
  63.                 pix.append(RGBs[cycle()%Lc])
  64.         id = ':'.join([str(int(z)) for z in (px,py)])
  65.         px = xx
  66.         print('Plasma Image '+id)
  67.         img.putdata(pix)
  68.         imgTk = ImageTk.PhotoImage(img)
  69.         canvas.create_image(0, 0, anchor=NW, image=imgTk)
  70.         canvas.update()
Add Comment
Please, Sign In to add comment