Lines Matching refs:rgb
358 def _rgb_to_6cube(rgb): argument
371 return tuple(0 if x < 48 else int(round(max(1, (x - 55)/40))) for x in rgb)
380 def _rgb_to_gray(rgb): argument
388 luma = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]
406 def _alloc_rgb(rgb, rgb2index={}): argument
419 if rgb in rgb2index:
420 return rgb2index[rgb]
426 _warn("Unable to allocate new RGB color ", rgb, ". Too many colors "
432 curses.init_color(color_index, *(int(round(1000*x/255)) for x in rgb))
433 rgb2index[rgb] = color_index
464 def _color_from_rgb(rgb): argument
479 return _alloc_rgb(rgb)
484 c6 = _rgb_to_6cube(rgb)
486 gray = _rgb_to_gray(rgb)
488 if dist(rgb, _6cube_to_rgb(c6)) < dist(rgb, _gray_to_rgb(gray)):
502 d = dist(rgb, tuple(int(round(255*c/1000))