U
ʗReD
@ s d dl mZ d dlmZ d dlmZmZmZ ddlm Z erHd dl
mZ G dd dZe
d krd d
lZd dlmZ d dlmZ d d
lmZmZ d dlmZ d dlmZ G dd dZe Zee d
S ) )sqrt) lru_cache)SequenceTuple
TYPE_CHECKING )ColorTripletTablec @ sn e Zd ZdZeeeeef dddZeedddZ dd d
dZ
edd
eeeef edddZdS )PalettezA palette of available colors.)colorsc C s
|| _ d S N)_colors)selfr r /builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_vendor/rich/palette.py__init__ s zPalette.__init__)numberreturnc C s t | j| S r
)r r )r r r r r __getitem__ s zPalette.__getitem__r
)r c
C s ddl m} ddlm} ddlm} ddlm} |dddd t| j d
ddd
}t
| j D ]2\}}|t|t
||d||j| dd q\|S )Nr ColorStyle)Textr indexRGBr r z colorsTright)titlecaption highlightcaption_justifyz )bgcolor)style)pip._vendor.rich.colorr pip._vendor.rich.styler pip._vendor.rich.textr pip._vendor.rich.tabler
lenr enumerateadd_rowstrreprfrom_rgb)r r r r r
tabler colorr r r __rich__ s( zPalette.__rich__i )maxsize)r/ r c sL |\t | jjttd fdd}ttt| j|d}|S )zFind a color from a palette that most closely matches a given color.
Args:
color (Tuple[int, int, int]): RGB components in range 0 > 255.
Returns:
int: Index of closes matching color.
)r r c sj | \}}}| d }| }| }| } d| | | d? d| | d| | | d? S )zGet the distance to a color. i i r )r red2green2blue2red_meanredgreenblue_sqrtblue1 get_colorgreen1red1r r get_color_distance: s
z)Palette.match.