Advertisement
here2share

# every_color.py

Dec 6th, 2018
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. # every_color.py
  2.  
  3. import math
  4. 0
  5. def common(z):
  6.     r,g,b,a = z
  7.     g += 256
  8.     b += 256*2
  9.     return (r+g+b)/80, z
  10. 0
  11.  
  12. from Tkinter import *
  13. import tkFileDialog
  14. from cStringIO import StringIO
  15. from PIL import ImageTk, ImageDraw, ImageChops, Image
  16. import base64, zlib
  17. import re
  18.  
  19. w = 200
  20. h = 200
  21.  
  22. root = Tk()
  23. root.geometry("%dx%d+-10+0"%(w,h))
  24. canvas = Canvas(root, width=w, height=h)
  25. canvas.grid()
  26.  
  27. size = w*(h/2)
  28. x = range(128,256)
  29. rgb = []
  30. for r in x:
  31.     if not r%32: print 256 - r
  32.     for g in x:
  33.         for b in x:
  34.             rgb += [(r+g+b,(r,g,b))]
  35. print 0
  36. print 'Now Sorting...'
  37. rgb.sort()
  38. print 'Sorted...'
  39. while 1:
  40.     for z in rgb:
  41.         rgb_img = [z[1]]*size
  42.         img = Image.new('RGB', (w,h/2))
  43.         r,g,b = [x-128 for x in z[1]]
  44.         img.putdata(tuple(rgb_img))
  45.         photo = ImageTk.PhotoImage(img)
  46.         canvas.create_image(0,h/4, image=photo, anchor='w')
  47.         canvas.create_text(100,20, text=z[1])
  48.         rgb2 = tuple([x-128 for x in z[1]])
  49.         rgb_img2 = [rgb2]*size
  50.         img2 = Image.new('RGB', (w,h/2))
  51.         img2.putdata(tuple(rgb_img2))
  52.         photo2 = ImageTk.PhotoImage(img2)
  53.         canvas.create_image(0,h-h/4, image=photo2, anchor='w')
  54.         canvas.create_text(100,120, fill='white', text=(rgb2))
  55.         root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement