
    &ThD                         d Z ddlmZmZmZmZ ddlmZ dZ	 d Z	d Z
d Zd	 Zd
 Ze	e
eeegZ	  G d d      Z G d de      Zy)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.)
    )logpisinsqrt   )o8g|=c                 n    || k  r| t         k  ryd|z  | z  S || z
  }d| z
  } | t         k  rydd|z  | z  z   S )Ng              ?      ?)EPSILONmiddleposs     \/home/stella.sw7ft.com/public_html/venv/lib/python3.12/site-packages/PIL/GimpGradientFile.pylinearr      sT    
f}G9v%%FlvGsV+++    c                 R    |t        d      t        t        | t                    z  z  S )Nr
   )r   maxr   r   s     r   curvedr   .   s"    3s8c#fg"67788r   c                 \    t        t         dz  t        t        | |      z  z         dz   dz  S )Ng       @r   )r   r   r   r   s     r   siner   2   s.    "sb6&##6667#=DDr   c                 >    t        dt        | |      dz
  dz  z
        S Nr      r   r   r   s     r   sphere_increasingr   6   s#    vfc*S0Q6677r   c                 >    dt        dt        | |      dz  z
        z
  S r   r   r   s     r   sphere_decreasingr   :   s#    cF63/144555r   c                       e Zd ZdZddZy)GradientFileNc           	         g }d}| j                   |   \  }}}}}}	t        |      D ](  }
|
|dz
  z  }||k  r!|dz  }| j                   |   \  }}}}}}	||k  r!||z
  }|t        k  r
 |	dd      }n |	||z
  |z  ||z
  |z        }t        t	        d|d   |d   z
  |z  |d   z   z  dz               }t        t	        d|d   |d   z
  |z  |d   z   z  dz               }t        t	        d|d   |d   z
  |z  |d   z   z  dz               }t        t	        d|d   |d   z
  |z  |d   z   z  dz               }|j                  ||z   |z   |z          + dj                  |      dfS )	Nr   r   r
      r      r   RGBA)gradientranger   r   intappendjoin)selfentriespaletteixx0x1xmrgb0rgb1segmentixwscalergbas                     r   
getpalettezGradientFile.getpaletteE   s   *.--*;'BD$w 	*AWq[!Aq&a26--2C/BD$ q& RA7{S)bAB!|< 3stAwa0E9DGCDsJKLA3stAwa0E9DGCDsJKLA3stAwa0E9DGCDsJKLA3stAwa0E9DGCDsJKLA NN1q519q=)+	*. xx &((r   )   )__name__
__module____qualname__r%   r<    r   r   r    r    B   s    H)r   r    c                       e Zd ZdZd Zy)GimpGradientFilez(File handler for GIMP's gradient format.c           	      V   |j                         d d dk7  rd}t        |      |j                         }|j                  d      r|j                         j                         }t	        |      }g }t        |      D ]  }|j                         j                         }|d d D cg c]  }t        |       }	}|	d   |	d   }}
|	d   }|	d	d
 }|	d
d }t        t	        |d            }t	        |d         }|dk7  rd}t        |      |j                  |
|||||f        || _        y c c}w )N   s   GIMP Gradientznot a GIMP gradient files   Name:    r   r   r   r#         zcannot handle HSV colour space)readlineSyntaxError
startswithstripr'   r&   splitfloatSEGMENTSOSErrorr(   r%   )r*   fpmsglinecountr%   r4   sr5   r6   r.   r/   r0   r1   r2   r3   cspaces                    r   __init__zGimpGradientFile.__init__h   s3   ;;="!11,Cc""{{} ??9%;;=&&(DD	u 	?A##%A#$Sb6*aq*A*qT1Q4B1BQq6DQr7Ds1R5z*G2ZF{6cl"OORRtW=>!	?$ !! +s   #D&N)r>   r?   r@   __doc__rW   rA   r   r   rC   rC   e   s
    2!!r   rC   N)rX   mathr   r   r   r   _binaryr   r   r   r   r   r   r   rO   r    rC   rA   r   r   <module>r[      se     $ # 
 ,9E86 FD"35FG  )  )F$!| $!r   