Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_grayscale_patterns.py
- from tkinter import *
- from PIL import Image, ImageTk
- import math
- from itertools import combinations
- ww = 500
- hh = 500
- sz = 10
- root = Tk()
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- t = range(0,256,25)
- TTT = []
- for grey in t:
- TTT += [(grey, grey, grey)]
- TTT *= (ww+hh)
- xy = []
- for y in range(0,hh,sz):
- for x in range(0,ww+1,sz):
- xy += [(x,y)]
- o = [i for i in range(255)]
- o = o[1:-1] + o[::-1]
- L = len(o)
- def make_rgb():
- return '#%02X%02X%02X'%(r,g,b)
- aaa = []
- bbb = []
- i = 0
- seq = 1 # sequences
- sub = 1
- while 1:
- ttt = TTT[:]
- if (bbb in aaa) or (sub > 25):
- aaa = []
- seq += 1
- sub = 1
- print (seq, sub)
- aaa += [bbb[:]]
- bbb = []
- canvas.delete('all')
- for x,y in xy:
- r,g,b = ttt.pop(-i)
- bbb += [r]
- i = (i-1)%seq
- canvas.create_rectangle((x, y, x-sz, y+sz), fill=make_rgb(), width=0)
- sub += 1
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement