
    W|h'                     d    S SK r S SKJr  S SKrS SKJr  S SKJr  S SK	J
r
  \ " S S\
5      5       rg)    N)	dataclass)Image)Clip)Effectc                       \ rS rSr% Sr\\S'   Sr\\S'   Sr	\\S'   Sr
\\S	'   S
r\\S'   S
r\\S'   S
r\\S'   S\S\4S jrSrg
)Rotate   al  
Rotates the specified clip by ``angle`` degrees (or radians) anticlockwise
If the angle is not a multiple of 90 (degrees) or ``center``, ``translate``,
and ``bg_color`` are not ``None``, there will be black borders.
You can make them transparent with:

>>> new_clip = clip.with_mask().rotate(72)

Parameters
----------

clip : VideoClip
A video clip.

angle : float
Either a value or a function angle(t) representing the angle of rotation.

unit : str, optional
Unit of parameter `angle` (either "deg" for degrees or "rad" for radians).

resample : str, optional
An optional resampling filter. One of "nearest", "bilinear", or "bicubic".

expand : bool, optional
If true, expands the output image to make it large enough to hold the
entire rotated image. If false or omitted, make the output image the same
size as the input image.

translate : tuple, optional
An optional post-rotate translation (a 2-tuple).

center : tuple, optional
Optional center of rotation (a 2-tuple). Origin is the upper left corner.

bg_color : tuple, optional
An optional color for area outside the rotated image. Only has effect if
``expand`` is true.
angledegunitbicubicresampleTexpandNcenter	translatebg_colorclipreturnc                 D  ^ ^^  [         R                  [         R                  [         R                  S.T R                     m[        T R                  S5      (       a  T R                  mOU 4S jmUUU 4S jnUR                  US/S9$ ! [
         a    [        S5      ef = f)zApply the effect to the clip.)bilinearnearestr   zE'resample' argument must be either 'bilinear', 'nearest' or 'bicubic'__call__c                    > TR                   $ )N)r
   )tselfs    Q/home/james-whalen/.local/lib/python3.13/site-packages/moviepy/video/fx/Rotate.py<lambda>Rotate.apply.<locals>.<lambda>L   s	    $**    c                 ~  > T" U5      nU " U5      nT	R                   S:X  a  [        R                  " U5      nUS-  nT	R                  (       Gd  T	R                  (       d  T	R
                  (       d  US:X  a  T	R                  (       a  U$ US:X  aL  T	R                  (       a;  [        UR                  5      S:X  a  SS/O/ SQn[        R                  " X4S9S S S	2   $ US
:X  aP  T	R                  (       a?  [        UR                  5      S:X  a  SS/O/ SQn[        R                  " X4S9S S 2S S S	24   $ US:X  a  T	R                  (       a  US S S	2S S S	24   $ 0 nT	R
                  b  T	R
                  US'   T	R                  b  T	R                  US'   T	R                  b  T	R                  US'   UR                  S:X  a  SnOSn[        R                  " [        R                  " [        R                  " Xc-  5      R                  [        R                   5      5      R"                  " U4T	R                  TS.UD65      U-  $ )Nradih  r   Z         )r$   r   r#   )axesi     	fillcolorr   r   float64g     o@)r   r   )r   mathdegreesr   r   r   r   lenshapenp	transposedtypearrayr   	fromarrayastypeuint8rotate)
	get_framer   r
   imr/   pillow_kwargsa	get_angler   r   s
          r   filterRotate.apply.<locals>.filterN   s   aLE1ByyE!U+SLE;;;t~~dmmQJDKKIRKT[[*-bhh-1*<A)I<<;DbDAAsl*-bhh-1*<A)I<<;AttGDDslddDbDj>)M}}(-1]]k*{{&*.++h'~~)-1^^k*
 xx9$ OOBHHQV$4$;$;BHH$EFMM&*kkHHU
 r   mask)apply_to)
r   BILINEARNEARESTBICUBICr   KeyError
ValueErrorhasattrr
   	transform)r   r   r;   r:   r   s   `  @@r   applyRotate.apply<   s    		!NN == == mm	H 4::z**

I,I0	d ~~fx~88y  	W 	s   =B	 	B )__name__
__module____qualname____firstlineno____doc__float__annotations__r   strr   r   boolr   tupler   r   r   rF   __static_attributes__rH   r   r   r   r      sa    %N LD#HcFDFEIuHeD9$ D94 D9r   r   )r*   dataclassesr   numpyr.   PILr   moviepy.Clipr   moviepy.Effectr   r   rH   r   r   <module>rY      s5     !    ! t9V t9 t9r   