import matplotlib.colors as colors import colorsys from math import * from tkinter import * # Data input & make dictionary dic_html={} fnameR='col_name_html.txt' fin=open(fnameR,'r') while 1: text=fin.readline() if not text: break text=text.strip() text=text.split() k=text[0] v=text[1] dic_html[k]=v fin.close() ls_h=[0,30,60,90,120,150,180,210,240,270,300,330] ls_s=[255,128, 64,255,128, 64,255,128, 64] ls_v=[255,255,255,192,192,192,128,128,128] n=len(ls_h) m=len(ls_s) scolor=[] for h in ls_h: for s,v in zip(ls_s,ls_v): r,g,b=colorsys.hsv_to_rgb(h/360, s/255, v/255) ir=int(round(r*255,0)) ig=int(round(g*255,0)) ib=int(round(b*255,0)) hrgb='#' hrgb=hrgb+'{0:0>2x}'.format(ir) hrgb=hrgb+'{0:0>2x}'.format(ig) hrgb=hrgb+'{0:0>2x}'.format(ib) scolor=scolor+[hrgb] print() pcolor=[] ncolor=[] for c in scolor: ir=int(c[1:2],16) ig=int(c[3:4],16) ib=int(c[5:6],16) h,s,v=colorsys.rgb_to_hsv(ir,ig,ib) x0=v*s*cos(2*pi*h) y0=v*s*sin(2*pi*h) z0=v dmax=10**10 for k in dic_html.keys(): ir=int(k[1:2],16) ig=int(k[3:4],16) ib=int(k[5:6],16) h,s,v=colorsys.rgb_to_hsv(ir,ig,ib) x1=v*s*cos(2*pi*h) y1=v*s*sin(2*pi*h) z1=v dis=sqrt((x1-x0)**2+(y1-y0)**2+(z1-z0)**2) if dis