here2share

# Tk_Alpha_Art_Test_9.py

Oct 16th, 2021 (edited)
560
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Tk_Alpha_Art_Test_9.py ZZZ
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. from itertools import combinations
  6. import string
  7. import random
  8. import tempfile
  9.  
  10. srcfilename=tempfile.mktemp(".py", "1400x680_")
  11. srcfilename=srcfilename.rsplit('\\',1)[0]+'\\alpha1400x680art.py'
  12. print srcfilename
  13.  
  14. rndi = random.randint
  15. rndc = random.choice
  16.  
  17. ww = 600
  18. hh = 600
  19.  
  20. root = Tk()
  21. root.title("Tk_Alpha_Art.py")
  22. root.geometry("%dx%d+0+0"%(ww,hh))
  23.  
  24. aaa = list(string.uppercase)
  25. bbb = list(string.lowercase)
  26.  
  27. ppp = [a+b for a in aaa+bbb for b in aaa+bbb]
  28. L = len(ppp)
  29. print L
  30. rgb2 = []
  31.  
  32. for y in range(hh):
  33.     for x in range(ww):
  34.         rgb2 += ['Q[('+'+'.join([ppp[z%L] for z in (x+hh,y,(x+y)/2)])+')%L]']
  35. 0
  36.  
  37. ttt = '''def alpha_art(vars):
  38.     exec(vars)
  39.     return '''
  40.  
  41. abc = ttt+'['+','.join(rgb2)+']'
  42.  
  43. '''
  44. temp=open(srcfilename, 'w')
  45. temp.write(abc)
  46. temp.close()
  47. webbrowser.open_new_tab(srcfilename)
  48. import alpha1400x680art
  49. '''
  50.  
  51. exec(abc)
  52.  
  53. rainbow=[]
  54. def z(r,g,b):
  55.     rainbow.append((r,g,b))
  56. r,g,b=255,0,0
  57. for g in range(256):
  58.     z(r,g,b)
  59. for r in range(254, -1, -1):
  60.     z(r,g,b)
  61. for b in range(256):
  62.     z(r,g,b)
  63. for g in range(254, -1, -1):
  64.     z(r,g,b)
  65. for r in range(256):
  66.     z(r,g,b)
  67. for b in range(254, -1, -1):
  68.     z(r,g,b)
  69. Q = rainbow[1:-1]+rainbow[::-1]
  70. L=len(Q)
  71.  
  72. def prep(i, polar, ccc):
  73.     vars = ''
  74.     for p in ppp[:ww+hh]: ### 1200 passes instead of 360000 passes !!!
  75.         t = str(i)
  76.         i = (i+polar)%L
  77.         ccc = ccc-1
  78.         if not ccc:
  79.             ccc = rndi(10,30)
  80.             polar = rndc(incr)
  81.         vars += p+'='+t+'\n'
  82.     rgb = alpha_art(vars)
  83.     return rgb
  84.  
  85. def draw():
  86.     image.putdata(rgb_)
  87.     photo = ImageTk.PhotoImage(image)
  88.     canvas.create_image(0,0,image=photo,anchor=NW)
  89.     canvas.update()
  90. 0
  91.  
  92. canvas = Canvas(root, width=ww, height=hh)
  93. canvas.pack()
  94.  
  95. image = Image.new("RGB", (ww,hh), (255,255,255))
  96.  
  97. ccccc = 255**3*2
  98.  
  99. i = rndi(0,L)
  100. t = 30
  101. incr = range(-t,t)
  102. ccc = 20
  103. polar = rndc(incr)
  104.  
  105. while 1:
  106.     rgb_ = prep(i, polar, ccc)
  107.     draw()
RAW Paste Data