45 def match(self, color: Tuple[int, int, int]) -> int:
46 """Find a color from a palette that most closely matches a given color.
49 color (Tuple[int, int, int]): RGB components in range 0 > 255.
52 int: Index of closes matching color.
54 red1, green1, blue1 = color
56 get_color = self.
_colors.__getitem__
59 """Get the distance to a color."""
61 red_mean = (red1 + red2) // 2
63 green = green1 - green2
66 (((512 + red_mean) * red * red) >> 8)
68 + (((767 - red_mean) * blue * blue) >> 8)