Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_quasi_colors.py
- from tkinter import *
- from PIL import Image, ImageTk
- import math
- ww = 256
- hh = 256
- root = Tk()
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- seq = 1 # sequences
- t = range(14)
- ttt = []
- for r in t:
- for g in t:
- for b in t:
- ttt += [(r,g,b)]
- ttt = sorted(ttt, key=sum)
- ttt.pop(0)
- Lt = len(ttt)
- cc = {}
- for x in range(ww):
- for y in range(hh):
- cc[x,y] = 0
- xy = []
- x2 = 256.0/ww
- y2 = 256.0/hh
- for y in range(hh):
- b = int(y*y2)
- for x in range(ww):
- a = int(x*x2)
- c = cc[a,b]
- xy += [(a,b,c)]
- cc[a,b] = c+1
- xy2 = xy[:]
- del cc # cc deleted
- img = Image.new("RGB",(ww,hh), "white")
- def draw():
- img.putdata(xy)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- canvas.update()
- draw()
- o = [i for i in range(255)]
- o = o[1:-1] + o[::-1]
- L = len(o)
- def make_rgb():
- return (o[int(r%L)],o[int(g%L)],o[int(b%L)])
- i = 0
- while 1:
- print (seq)
- seq += 1
- for k, (rrr,ggg,bbb) in enumerate(xy2):
- r2,g2,b2 = ttt[0]
- ttt.insert(Lt-i, ttt.pop(0))
- i = (i-1)%3
- r,g,b = (rrr+r2,ggg+g2,bbb+b2)
- xy2[k] = r,g,b
- rgb = make_rgb()
- xy[k] = rgb
- draw()
Add Comment
Please, Sign In to add comment