Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_quasi_colors_2.py
- from tkinter import *
- from PIL import Image, ImageTk
- import math
- from itertools import combinations
- ww = 600
- hh = 600
- sz = 30
- 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
- rgb = []
- xy = []
- x2 = 256.0/ww
- y2 = 256.0/hh
- for y in range(0,hh,sz):
- b = int(y*y2)
- for x in range(0,ww,sz):
- a = int(x*x2)
- c = cc[a,b]
- rgb += [(a,b,c)]
- cc[a,b] = c+1
- xy += [(x,y)]
- del cc # cc deleted
- img = Image.new("RGB",(ww,hh), "white")
- o = [i for i in range(255)]
- o = o[1:-1] + o[::-1]
- L = len(o)
- def make_rgb():
- return '#%02X%02X%02X'%(o[int(r%L)],o[int(g%L)],o[int(b%L)])
- i = 0
- while 1:
- print (seq)
- seq += 1
- canvas.delete('all')
- for k, (rrr,ggg,bbb) in enumerate(rgb):
- 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)
- rgb[k] = r,g,b
- x,y = xy[k]
- canvas.create_rectangle((x, y, x-sz, y+sz), fill=make_rgb(), width=0)
- canvas.update()
Add Comment
Please, Sign In to add comment