관리-도구
편집 파일: palette.cpython-311.pyc
� �DgD � �( � d dl mZ d dlmZ d dlmZmZmZ ddlm Z erd dl mZ G d� d� � Ze d k rZd d lZd dlmZ d dlmZ d d lmZmZ d dlmZ d dlmZ G d� d� � Z e� � Ze� e� � � � d S d S )� )�sqrt)� lru_cache)�Sequence�Tuple� TYPE_CHECKING� )�ColorTriplet��Tablec � � e Zd ZdZdeeeeef fd�Zdedefd�Z dd�Z ed � � � deeeef defd�� � Zd S )�PalettezA palette of available colors.�colorsc � � || _ d S �N)�_colors)�selfr s �x/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/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 r c �T � ddl m} ddlm} ddlm} ddlm} |dddd t | j � � � d �dd� � � }t | j � � D ]S\ }}|� t |� � t |� � |d | |j |� �� � �� � � � �T|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�0�0�0�0�0�0�0�0�0�.�.�.�.�.�.�0�0�0�0�0�0��������4�<�(�(�1�1�1��#� � � �� &�d�l�3�3� � �L�E�5��M�M��E� � ��U�����X�U�U�>�5�>�5�3I�%J�%J�%J�K�K�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�"2��D�&�%��t���)�H���+�C��V�O�E��5�=�D��5���>�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�,� � �c� �e� � � � � � � � � � � ��c�$�,�/�/�0�0�6H�I�I�I� ��r N)r r ) �__name__� __module__�__qualname__�__doc__r r rK r r r r5 r rP r<