Advertisement
here2share

# Tk_Gritty_Art_v2_1400x700.py

Nov 10th, 2021
1,424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.96 KB | None | 0 0
  1. # Tk_Gritty_Art_v2_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_Gritty_Art_v2_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. vars = []
  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.             vars.append(abc[z])
  52.             xy[t].append(abc[z])
  53. 0
  54.  
  55. vars = list(set(vars))
  56.  
  57. matrix = '['+','.join(['Q[{}+{}+{}+{}]'.format(*z) for z in xy])+']'
  58.  
  59. p = 1079281
  60. ppp = p*2
  61. t = len(matrix)
  62.  
  63. # hack for the color list... but slows quite a bit
  64. exec("def o(): return "+str(matrix[:t/2])+"]+eval('['+str(matrix[t/2+1:]))")
  65.  
  66. rainbow=[]
  67. def z(r,g,b):
  68.     rainbow.append((r,g,b))
  69. r,g,b=255,0,0
  70. for g in range(256):
  71.     z(r,g,b)
  72. for r in range(254, -1, -1):
  73.     z(r,g,b)
  74. for b in range(256):
  75.     z(r,g,b)
  76. for g in range(254, -1, -1):
  77.     z(r,g,b)
  78. for r in range(256):
  79.     z(r,g,b)
  80. for b in range(254, -1, -1):
  81.     z(r,g,b)
  82. Q = rainbow[1:-1]+rainbow[::-1]
  83. LQ = len(Q)
  84.  
  85. for k,v in enumerate(vars):
  86.     exec(v+'='+str(Q[k%LQ]))
  87.  
  88. def draw():
  89.     image.putdata(rgb)
  90.     photo = ImageTk.PhotoImage(image)
  91.     canvas.create_image(0,0,image=photo,anchor='nw')
  92.     canvas.update()
  93. 0
  94.  
  95. canvas = Canvas(root, width=ww, height=hh)
  96. canvas.pack()
  97.  
  98. image = Image.new("RGB", (ww,hh), (255,255,225))
  99.  
  100. ccc = LQ/4
  101.  
  102. vars.sort()
  103.  
  104. iii = (255**3)/4
  105.  
  106. rnd = 80
  107. while 1:
  108.     for _ in xrange(9999999):
  109.         for zzz in vars:
  110.             iii = (iii+ri_(0,rnd)-rnd/2)%ccc
  111.             exec(zzz+'='+str(iii))
  112.         rgb = o()
  113.  
  114.         draw()
  115.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement