U
    a+d                     @   sX   d dl Zd dlmZ zd dlmZ dZdd ZW n ek
rH   dZY nX dd
dZ	dS )    N)apply_to_mask)ImageTc                 C   s   t t| j|||dS )N)expandresample)nparrayr   Z	fromarrayrotate)Zpicangler   r    r
   ;/tmp/pip-unpacked-wheel-0yp4gafk/moviepy/video/fx/rotate.pypil_rotater   s    r   Fdegbicubicc                    sn   t jt jt jd tds2
   fdd| jr@ddgndddgfdd	}| j|d
gdS )a  
    Change unit to 'rad' to define angles as radians.
    If the angle is not one of 90, 180, -90, -180 (degrees) there will be
    black borders. You can make them transparent with

    >>> newclip = clip.add_mask().rotate(72)

    Parameters
    ===========

    clip
      A video clip

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

    unit
      Unit of parameter `angle` (either `deg` for degrees or `rad` for radians)

    resample
      One of "nearest", "bilinear", or "bicubic".

    expand
      Only applIf False, the clip will maintain the same True, the clip will be resized so that the whole
    )ZbilinearZnearestr   __call__c                    s    S )Nr
   )t)ar
   r   <lambda>0       zrotate.<locals>.<lambda>   r      c                    s    |}| |}dkr*d| dt j  }|dkrNrNt j|dd d d S |dkrzrzt j|dd d d d df S |dkrr|d d dd d df S tstd	nt||d
S d S )NZradg     v@r   Z   )Zaxesi)   iLzqWithout "Pillow" installed, only angles 90, -90,180 are supported, please install "Pillow" withpip install pillow)r   r   )r   piZ	transpose	PIL_FOUND
ValueErrorr   )Zgfr   r   Zim)r	   r   r   transpounitr
   r   fl4   s     
zrotate.<locals>.flmask)Zapply_to)r   ZBILINEARZNEARESTZBICUBIChasattrZismaskr   )Zclipr	   r   r   r   r   r
   )r   r	   r   r   r   r   r   r      s    
r   )r   r   T)
Znumpyr   Zmoviepy.decoratorsr   ZPILr   r   r   ImportErrorr   r
   r
   r
   r   <module>   s   
