here2share

# Tk_Pattern_Search.py

Feb 28th, 2021
728
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Tk_Pattern_Search.py -- experimenting
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. import random
  6. import math
  7. import time
  8.  
  9. ww = 640
  10. hh = 640
  11. root = Tk()
  12. root.title("Tk Pattern Search")
  13. root.geometry("%dx%d+0+0"%(ww,hh))
  14. canvas = Canvas(root, width=ww, height=hh)
  15. canvas.grid()
  16.  
  17. RGBs = []
  18. def z():
  19.     RGBs.append((r,g,b))
  20. r,g,b = 255,0,0
  21. for g in range(256):
  22.     z()
  23. for r in range(254, -1, -1):
  24.     z()
  25. for b in range(256):
  26.     z()
  27. for g in range(254, -1, -1):
  28.     z()
  29. for r in range(256):
  30.     z()
  31. for b in range(254, -1, -1):
  32.     z()
  33.  
  34. Lc = len(RGBs)
  35.  
  36. t = (ww*hh)/Lc+1
  37. gradient = []
  38. for z in RGBs:
  39.     gradient.extend([z]*t)
  40.    
  41. gradient = gradient[:ww*hh]
  42.  
  43. img = Image.new("RGB",(ww,hh), "white")
  44.  
  45. ttt = 1
  46. while 1:
  47.     pix = []
  48.     t = 0
  49.     for x in range(ww):
  50.         for y in range(hh):
  51.             pix.append((x+t%ttt))
  52.             t += 1
  53.     pix = [x for y, x in sorted(zip(pix, gradient))]
  54.  
  55.     img.putdata(pix)
  56.     imgTk = ImageTk.PhotoImage(img)
  57.     canvas.create_image(0, 0, anchor=NW, image=imgTk)
  58.     root.update()
  59.     print ttt
  60.     ttt += 2
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×