Advertisement
here2share

# Py3Tk_Gradient_Art_1400x700.py

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