here2share

# Tk_Alpha_Art_Test_10.py

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