Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_rgb_brightness.py
- from Tkinter import *
- from PIL import Image, ImageTk
- from math import *
- import random
- import re
- colors = 4096*4096
- w = h = 600
- xyc = []
- for y in range(0,h):
- for x in range(0,w):
- rgb = int((y*6.4)*4096+((x*6.4)%4096))
- r,g,b = (rgb & 0xff, (rgb >> 8) & 0xff, rgb >> 16)
- lum = sqrt(0.299*r + 0.587*g + 0.114*b)
- xyc.append([lum,(r,g,b)])
- xyc.sort(key=lambda z: z[0])
- root = Tk()
- root.title("Tk rgb brightness")
- canvas = Canvas(root, width=w, height=h)
- canvas.pack()
- for y in range(0,h):
- zzz,xyc = xyc[:w],xyc[w:]
- # zzz.sort(key=lambda z: z[1][1]+z[1][2])
- for x in range(0,w):
- z,cx = zzz.pop()
- canvas.create_line((x,y,x+1,y+1),fill='#%02x%02x%02x' % cx)
- root.update()
- 0
- root.mainloop()
Add Comment
Please, Sign In to add comment