here2share

# Tk_Gradient_Art_1400x700.py

Nov 12th, 2021 (edited)
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.14 KB | None | 0 0
  1. # Tk_Gradient_Art_1400x700.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import string
  6. import time
  7. import random
  8. import math
  9.  
  10. from itertools import product
  11.  
  12. ri_ = random.randint
  13. rs_ = random.shuffle
  14. rc_ = random.choice
  15.  
  16. tx_ =  time.time
  17.  
  18. ww = 1400
  19. hh = 700
  20.  
  21. root = Tk()
  22. root.title("Tk_Gradient_Art_1400x700")
  23. root.geometry("%dx%d+-10+0"%(ww,hh))
  24.  
  25. alpha = string.letters
  26.  
  27. xy = [[] for z in range(ww*hh)]
  28.  
  29. abc = []
  30.  
  31. for x in alpha:
  32.     for y in alpha+'0123456789':
  33.         for z in alpha+'0123456789':
  34.             t = x+y+z
  35.             if not t.isalpha():
  36.                 exec(t+'=(255,255,0)')
  37.                 abc.append(t)
  38.                
  39. L = len(abc)
  40. print L
  41.  
  42. v = []
  43. for y in range(hh):
  44.     for x in range(ww):
  45.         t = y*ww+x
  46.         a = y
  47.         b = x+ww
  48.         c = y+ww*2-x
  49.         d = y+ww*3+x
  50.         for z in [a,b,c,d]:
  51.             v.append(abc[z])
  52.             xy[t].append(abc[z])
  53. 0
  54.  
  55. print '...'
  56.  
  57. vvv = []
  58. for z in list(set(v)):
  59.     vvv.append((v.index(z),z))
  60.  
  61. vvv.sort()
  62.  
  63. matrix = '['+','.join(['Q[{}+{}+{}+{}]'.format(*z) for z in xy])+']'
  64.  
  65. p = 1079281
  66. ppp = p*2
  67. t = len(matrix)
  68.  
  69. # hack for the color list... but slows quite a bit
  70. exec("def o(): return "+str(matrix[:t/2])+"]+eval('['+str(matrix[t/2+1:]))")
  71.  
  72. rainbow=[]
  73. def z(r,g,b):
  74.     rainbow.append((r,g,b))
  75. r,g,b=255,0,0
  76. for g in range(256):
  77.     z(r,g,b)
  78. for r in range(254, -1, -1):
  79.     z(r,g,b)
  80. for b in range(256):
  81.     z(r,g,b)
  82. for g in range(254, -1, -1):
  83.     z(r,g,b)
  84. for r in range(256):
  85.     z(r,g,b)
  86. for b in range(254, -1, -1):
  87.     z(r,g,b)
  88. Q = rainbow[1:-1]+rainbow[::-1]
  89. LQ = len(Q)
  90.  
  91. vars = []
  92. for k,v in enumerate(vvv):
  93.     exec(v[1]+'='+str(Q[k%LQ]))
  94.     vars += [v[1]]
  95.  
  96. def draw():
  97.     image.putdata(rgb)
  98.     photo = ImageTk.PhotoImage(image)
  99.     canvas.create_image(0,0,image=photo,anchor='nw')
  100.     canvas.update()
  101. 0
  102.  
  103. canvas = Canvas(root, width=ww, height=hh)
  104. canvas.pack()
  105.  
  106. image = Image.new("RGB", (ww,hh), (255,255,225))
  107.  
  108. ccc = LQ/4
  109.  
  110. iii = (255**3)/4
  111.  
  112. wave = []
  113. for z in range(200):
  114.     for i in range(201-z):
  115.         wave.append((z-100)*0.005)
  116. Lw = len(wave)
  117.  
  118. rnd = 3
  119. while 1:
  120.     for _ in xrange(9999999):
  121.         for z in vars:
  122.             rnd = rc_(wave)
  123.             iii = (iii+rnd)%ccc
  124.             exec(z+'='+str(int(iii)))
  125.         rgb = o()
  126.  
  127.         draw()
  128.  
Add Comment
Please, Sign In to add comment