Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Alpha_Art_Test_9.py ZZZ
- from Tkinter import *
- from PIL import Image, ImageTk
- from itertools import combinations
- import string
- import random
- import tempfile
- srcfilename=tempfile.mktemp(".py", "1400x680_")
- srcfilename=srcfilename.rsplit('\\',1)[0]+'\\alpha1400x680art.py'
- print srcfilename
- rndi = random.randint
- rndc = random.choice
- ww = 600
- 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 = []
- for y in range(hh):
- for x in range(ww):
- rgb2 += ['Q[('+'+'.join([ppp[z%L] for z in (x+hh,y,(x+y)/2)])+')%L]']
- 0
- ttt = '''def alpha_art(vars):
- exec(vars)
- return '''
- abc = ttt+'['+','.join(rgb2)+']'
- '''
- temp=open(srcfilename, 'w')
- temp.write(abc)
- temp.close()
- webbrowser.open_new_tab(srcfilename)
- import alpha1400x680art
- '''
- exec(abc)
- 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()
Add Comment
Please, Sign In to add comment