Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_random_ref_scroll_art.py
- from tkinter import *
- from PIL import Image, ImageTk
- import math
- import random
- ww = 600
- hh = 600
- def draw():
- image.putdata(rgb)
- photo = ImageTk.PhotoImage(image)
- canvas.create_image(0,0,image=photo,anchor=NW)
- canvas.update()
- root = Tk()
- root.title("Tk_random_ref_scroll_art")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- image = Image.new("RGB", (ww,hh), (255,255,255))
- black = [(0,)*3]
- white = [(255,)*3]
- zzz = [i for i in range(10)]
- zzz = zzz[1:-1] + zzz[::-1]
- ref = []
- while len(ref) < ww+5:
- ref.extend(zzz)
- ref = ref[:ww+2]
- rgb = white*(ww*hh)
- while 1:
- ttt = []
- buf = []
- iii = 1
- while len(ttt) < ww:
- t = 0
- for i in [iii-1,iii,iii+1]:
- t += ref[i]
- t = t//3
- t = random.randint(t-3,t) % 100
- buf += [t]
- if t < 7:
- ttt += black
- else:
- ttt += white
- iii += 1
- ref = buf * 2
- ref = [ref[-1]] + ref
- rgb.extend(ttt[:ww])
- rgb = rgb[-ww*hh:]
- draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement