function get_color_indx,color
tvlct,r,g,b,/get
vecs = replicate(1.,n_elements(r)) # reform(color)
tbl = [[r],[g],[b]]
d = sqrt( total((vecs-tbl)^2,2) )
m = min(d,bin)
return,byte(bin)
end
function get_colors,colors=cols,array=array,input
@colors_com
dt = size(/type,input)
if dt ge 1 and dt le 5 then return,round(input)
magenta = get_color_indx([1,0,1]*255)
red = get_color_indx([1,0,0]*255)
yellow = get_color_indx([1,1,0]*255)
green = get_color_indx([0,1,0]*255)
cyan = get_color_indx([0,1,1]*255)
blue = get_color_indx([0,0,1]*255)
white = get_color_indx([1,1,1]*255)
black = get_color_indx([0,0,0]*255)
colors = [black,magenta,blue,cyan,green,yellow,red,white]
cols = colors
col = {black:black,magenta:magenta,blue:blue,cyan:cyan,green:green, $
yellow:yellow,red:red,white:white}
if dt eq 7 then begin
map = bytarr(256)+!p.color
map[byte('xmbcgyrw')] = colors
map[byte('XMBCGYRW')] = colors
map[byte('0123456789')] = bindgen(10)
map[byte('Dd')] = !p.color
map[byte('Zz')] = !p.background
cb = reform(byte(input))
return,map[cb]
endif
if keyword_set(array) then return,colors else return,col
end