Advertisement
here2share

# Tk_random_ref_scroll_art.py

Mar 6th, 2023
1,355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. # Tk_random_ref_scroll_art.py
  2.  
  3. from tkinter import *
  4. from PIL import Image, ImageTk
  5. import math
  6. import random
  7.  
  8. ww = 600
  9. hh = 600
  10.  
  11. def draw():
  12.     image.putdata(rgb)
  13.     photo = ImageTk.PhotoImage(image)
  14.     canvas.create_image(0,0,image=photo,anchor=NW)
  15.     canvas.update()
  16.    
  17.  
  18. root = Tk()
  19. root.title("Tk_random_ref_scroll_art")
  20. root.geometry("%dx%d+0+0"%(ww,hh))
  21.    
  22. canvas = Canvas(root, width=ww, height=hh)
  23. canvas.pack()
  24.  
  25. image = Image.new("RGB", (ww,hh), (255,255,255))
  26.  
  27. black = [(0,)*3]
  28. white = [(255,)*3]
  29.  
  30. zzz = [i for i in range(10)]
  31. zzz = zzz[1:-1] + zzz[::-1]
  32.  
  33. ref = []
  34. while len(ref) < ww+5:
  35.     ref.extend(zzz)
  36. ref = ref[:ww+2]
  37.  
  38. rgb = white*(ww*hh)
  39.  
  40. while 1:
  41.     ttt = []
  42.     buf = []
  43.     iii = 1
  44.     while len(ttt) < ww:
  45.         t = 0
  46.         for i in [iii-1,iii,iii+1]:
  47.             t += ref[i]
  48.         t = t//3
  49.         t = random.randint(t-3,t) % 100
  50.         buf += [t]
  51.         if t < 7:
  52.             ttt += black
  53.         else:
  54.             ttt += white
  55.         iii += 1
  56.     ref = buf * 2
  57.     ref = [ref[-1]] + ref
  58.     rgb.extend(ttt[:ww])
  59.     rgb = rgb[-ww*hh:]
  60.     draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement