
    g	                     <    d dl mZ d dlmZ e G d de             Zy)    )	dataclass)Effectc                   L    e Zd ZU dZdZeed<   dZeed<   dZeed<   	 d	dZ	d Z
y)

AccelDecelad  Accelerates and decelerates a clip, useful for GIF making.

    Parameters
    ----------

    new_duration : float
      Duration for the new transformed clip. If None, will be that of the
      current clip.

    abruptness : float
      Slope shape in the acceleration-deceleration function. It will depend
      on the value of the parameter:

      * ``-1 < abruptness < 0``: speed up, down, up.
      * ``abruptness == 0``: no effect.
      * ``abruptness > 0``: speed down, up, down.

    soonness : float
      For positive abruptness, determines how soon the transformation occurs.
      Should be a positive number.

    Raises
    ------

    ValueError
      When ``sooness`` argument is lower than 0.

    Examples
    --------

    The following graphs show functions generated by different combinations
    of arguments, where the value of the slopes represents the speed of the
    videos generated, being the linear function (in red) a combination that
    does not produce any transformation.

    .. image:: /_static/medias/accel_decel-fx-params.png
      :alt: acced_decel FX parameters combinations
    Nnew_duration      ?
abruptnesssoonnessc                 :    d|z   fd}| |||z  |z        z  S )Nr   c                 T    fdfd}| dk   |       z  | dk\   ||       z  z   S )Nc                      ddz
  z  | z  z  S )N      ?    )tas    d/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/moviepy/video/fx/AccelDecel.pyf1z1AccelDecel._f_accel_decel.<locals>._f.<locals>.f19   s    Q'1a400    c                      d d| z
        z
  S )Nr   r   )r   r   s    r   f2z1AccelDecel._f_accel_decel.<locals>._f.<locals>.f2<   s    2a!e9}$r   r   r   )r   r   r   r   s     @r   _fz%AccelDecel._f_accel_decel.<locals>._f8   s4    1% Gr!u$SBqE'999r   r   )selfr   old_durationr   r	   r
   r   r   s          @r   _f_accel_decelzAccelDecel._f_accel_decel3   s0     *	: b!l"2x!?@@@r   c                       j                   j                   _          j                  dk  rt        d      j	                   fd      j                   j                         S )zApply the effect to the clip.r   z%'sooness' should be a positive numberc                     j                  | j                  j                  j                  j                        S )N)r   r   r   r	   r
   )r   durationr   r	   r
   )r   clipr   s    r   <lambda>z"AccelDecel.apply.<locals>.<lambda>L   s8    d))!]]!..?? *  r   )r   r   r
   
ValueErrortime_transformwith_duration)r   r   s   ``r   applyzAccelDecel.applyC   s]    $ $D==1DEE""
 -))
*	+r   )r   r   )__name__
__module____qualname____doc__r   float__annotations__r	   r
   r   r$   r   r   r   r   r      s:    %N L%JHe GJA +r   r   N)dataclassesr   moviepy.Effectr   r   r   r   r   <module>r-      s)    ! ! L+ L+ L+r   