Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Alpha_Art_Test_10.py ZZZ still out of memory issue when 1400x680
- from Tkinter import *
- from PIL import Image, ImageTk
- from itertools import combinations
- import string
- import random
- import tempfile
- import os
- t=tempfile.mktemp(".py", "1400x680_")
- file='\\alpha1400x680art.py'
- folder=t.rsplit('\\',1)[0]
- print folder+file
- rndi = random.randint
- rndc = random.choice
- ww = 800
- hh = 600
- root = Tk()
- root.title("Tk_Alpha_Art.py")
- root.geometry("%dx%d+0+0"%(ww,hh))
- aaa = list(string.uppercase)
- bbb = list(string.lowercase)
- ppp = [a+b for a in aaa+bbb for b in aaa+bbb]
- L = len(ppp)
- print L
- rgb2 = []
- if not os.path.isfile(folder+file):
- for y in range(hh):
- for x in range(ww):
- rgb2 += ['Q[('+'+'.join([ppp[z%L]+'_' for z in (x+hh,y,ww-(x+y)/2)])+')%L]']
- 0
- ttt = '''def alpha_art(vars):
- exec(vars)
- return '''
- abc = ttt+'['+','.join(rgb2)+']'
- print "creating file..."
- temp=open(folder+file, 'w')
- temp.write(abc)
- temp.close()
- print "modulating file..."
- execfile(folder+file)
- print "file modulated..."
- rainbow=[]
- def z(r,g,b):
- rainbow.append((r,g,b))
- r,g,b=255,0,0
- for g in range(256):
- z(r,g,b)
- for r in range(254, -1, -1):
- z(r,g,b)
- for b in range(256):
- z(r,g,b)
- for g in range(254, -1, -1):
- z(r,g,b)
- for r in range(256):
- z(r,g,b)
- for b in range(254, -1, -1):
- z(r,g,b)
- Q = rainbow[1:-1]+rainbow[::-1]
- L=len(Q)
- def prep(i, polar, ccc):
- vars = ''
- for p in ppp[:ww+hh]: ### 1200 passes instead of 360000 passes !!!
- t = str(i)
- i = (i+polar)%L
- ccc = ccc-1
- if not ccc:
- ccc = rndi(10,30)
- polar = rndc(incr)
- vars += p+'_='+t+'\n'
- rgb = alpha_art(vars)
- return rgb
- def draw():
- image.putdata(rgb_)
- photo = ImageTk.PhotoImage(image)
- canvas.create_image(0,0,image=photo,anchor=NW)
- canvas.update()
- 0
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- image = Image.new("RGB", (ww,hh), (255,255,255))
- ccccc = 255**3*2
- i = rndi(0,L)
- t = 30
- incr = range(-t,t)
- ccc = 20
- polar = rndc(incr)
- while 1:
- rgb_ = prep(i, polar, ccc)
- draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement