관리-도구
편집 파일: palette.cpython-312.pyc
� G��eD � � � d dl mZ d dlmZ d dlmZmZmZ ddlm Z erd dl mZ G d� d� Ze d k( rLd d lZd dlmZ d dlmZ d d lmZmZ d dlmZ d dlmZ G d� d� Z e� Zej7 e� � y y )� )�sqrt)� lru_cache)�Sequence�Tuple� TYPE_CHECKING� )�ColorTriplet��Tablec �z � e Zd ZdZdeeeeef fd�Zdedefd�Z d d�Z ed� � d eeeef defd�� Zy)�PalettezA palette of available colors.�colorsc � � || _ y �N)�_colors)�selfr s ��/builddir/build/BUILDROOT/alt-python312-pip-23.3.1-1.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pip/_vendor/rich/palette.py�__init__zPalette.__init__ s � ���� �number�returnc �, � t | j | � S r )r r )r r s r �__getitem__zPalette.__getitem__ s � ��T�\�\�&�1�2�2r c �< � ddl m} ddlm} ddlm} ddlm} |dddd t | j � � d �dd� � }t | j � D ]F \ }}|j t |� t |� |d | |j |� �� �� � �H |S )Nr ��Color��Style)�Textr �index�RGBr r z colorsT�right)�title�caption� highlight�caption_justifyz )�bgcolor)�style)�pip._vendor.rich.colorr �pip._vendor.rich.styler �pip._vendor.rich.textr �pip._vendor.rich.tabler �lenr � enumerate�add_row�str�repr�from_rgb)r r r r r �tabler �colors r �__rich__zPalette.__rich__ s� � �0�0�.�0�������4�<�<�(�)��1��#� �� &�d�l�l�3� �L�E�5��M�M��E� ��U���X�U�>�5�>�>�5�3I�%J�K� � � �r i )�maxsizer4 c �� ������ |\ ���t �| j j �dt dt f�����fd�}t t t | j � � |�� }|S )z�Find 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 � �� � | � \ }}}�|z dz }�|z }�|z }� |z } �d|z |z |z dz d|z |z z d|z |z |z dz z � S )zGet the distance to a color.� i � � i� � ) r �red2�green2�blue2�red_mean�red�green�blue�_sqrt�blue1� get_color�green1�red1s �����r �get_color_distancez)Palette.match.<locals>.get_color_distance: s� �� �"+�E�"2��D�&�%��t���)�H���+�C��V�O�E��5�=�D����>�S�(�3�.�1�4��e�)�e�#�$��8�^�t�+�d�2�q�8�:�� r )�key)r r r �int�float�min�ranger- ) r r4 rI � min_indexrD rE rF rG rH s @@@@@r �matchz Palette.match, s` �� � $���f�e����L�L�,�,� � �c� �e� � � ��c�$�,�,�/�0�6H�I� ��r N)r r ) �__name__� __module__�__qualname__�__doc__r r rK r r r r5 r rP r<