o �J�h��@s�dZddlmZddlmZmZmZmZddlm Z m Z ddl m Z dZ dd d �Zddd�Zddd�Zddd�Zddd�ZeeeeegZ Gdd�d�ZGdd�de�ZdS)z� Stuff to translate curve segments to palette values (derived from the corresponding code in GIMP, written by Federico Mena Quintero. See the GIMP distribution for more information.) �)� annotations)�log�pi�sin�sqrt)�IO�Callable�)�o8g�����|�=�middle�float�pos�returncCsL||kr|tkr dSd||S||}d|}|tkrdSdd||S)Ng��?��?)�EPSILON�r r �r�RC:\pinokio\api\whisper-webui.git\app\env\lib\site-packages\PIL\GimpGradientFile.py�linear s rcCs|td�tt|t��S)Nr)r�maxrrrrr�curved/�rcCs$tt dtt||��ddS)Ng@r)rrrrrrr�sine3s$rcCstdt||�dd�S�Nr��rrrrrr�sphere_increasing7rrcCsdtdt||�d�Srrrrrr�sphere_decreasing;rrc@s&eZdZUdZded<d d d d �ZdS) � GradientFileNzblist[tuple[float, float, float, list[float], list[float], Callable[[float, float], float]]] | None�gradient��entries�intr�tuple[bytes, str]cCs~|jdusJ�g}d}|j|\}}}}}} t|�D]�} | |d} || kr9|d7}|j|\}}}}}} || ks&||} | tkrG| dd�} n | ||| | || �} ttd|d|d| |dd��}ttd|d|d| |dd��}ttd|d|d| |dd��}ttd|d|d| |dd��}|�||||�qd�|�dfS) Nrr r��r���RGBA)r �rangerr r#�append�join)�selfr"�palette�ix�x0�x1�xm�rgb0�rgb1�segment�i�x�w�scale�r�g�b�arrr� getpaletteRs(  � ,,,,zGradientFile.getpalette)r!)r"r#rr$)�__name__� __module__� __qualname__r �__annotations__r=rrrrrCs  �rc@seZdZdZd dd�ZdS) �GimpGradientFilez(File handler for GIMP's gradient format.�fp� IO[bytes]r�Nonec Cs�|��dd�dkrd}t|��|��}|�d�r|����}t|�}g|_t|�D]P}|����}dd�|dd�D�}|d|d }} |d } |d d �} |d d�} tt|d�} t|d �}|dkrnd}t |��|j� || | | | | f�q*dS)N� s GIMP Gradientznot a GIMP gradient filesName: cSsg|]}t|��qSr)r )�.0r6rrr� <listcomp>�sz-GimpGradientFile.__init__.<locals>.<listcomp>� rrr r&�� zcannot handle HSV colour space) �readline� SyntaxError� startswith�stripr#r r)�split�SEGMENTS�OSErrorr*)r,rC�msg�line�countr5�sr7r/r0r1r2r3r4Zcspacerrr�__init__vs,       �zGimpGradientFile.__init__N)rCrDrrE)r>r?r@�__doc__rWrrrrrBssrBN)r r r r rr )rX� __future__r�mathrrrr�typingrr�_binaryr rrrrrrrQrrBrrrr�<module>s        0
Memory