
    g                     H    d dl mZ d dlmZ d dlmZ e G d de             Zy)    )	dataclass)Clip)Effectc                       e Zd ZU dZdZeed<   dZeed<   dZeed<   dZ	eed<   dZ
eed<   dZeed<   dZeed	<   dZeed
<   dedefdZy)CropaH  Effect to crop a clip to get a new clip in which just a rectangular
    subregion of the original clip is conserved. `x1,y1` indicates the top left
    corner and `x2,y2` is the lower right corner of the cropped region. All
    coordinates are in pixels. Float numbers are accepted.

    To crop an arbitrary rectangle:

    >>> Crop(x1=50, y1=60, x2=460, y2=275)

    Only remove the part above y=30:

    >>> Crop(y1=30)

    Crop a rectangle that starts 10 pixels left and is 200px wide

    >>> Crop(x1=10, width=200)

    Crop a rectangle centered in x,y=(300,400), width=50, height=150 :

    >>> Crop(x_center=300, y_center=400, width=50, height=150)

    Any combination of the above should work, like for this rectangle
    centered in x=300, with explicit y-boundaries:

    >>> Crop(x_center=300, width=400, y1=100, y2=600)

    Nx1y1x2y2widthheightx_centery_centerclipreturnc                      j                   r+ j                   j                   j                   z    _        n6 j                   r* j                   j                   j                   z
   _         j                  r+ j                   j                   j                  z    _        n6 j                  r* j
                   j
                   j                  z
   _         j                  rC j                   j                   dz  z
   j                   j                   dz  z   c _         _         j                  rC j                   j                  dz  z
   j                   j                  dz  z   c _         _         j                  xs d _         j                  xs d _         j                  xs |j                  d    _         j
                  xs |j                  d    _        |j                   fddg      S )zApply the effect to the clip.   r      c                     | t        j                        t        j                        t        j                        t        j                        f   S )N)intr	   r   r   r
   )frameselfs    ^/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/moviepy/video/fx/Crop.py<lambda>zCrop.apply.<locals>.<lambda>L   s>    %DGGs477|+S\CL-HH     mask)apply_to)
r   r   r
   r   r	   r   r   r   sizeimage_transform)r   r   s   ` r   applyz
Crop.apply.   s   ::$''-gg

*DGZZDGG/gg

*DG;;477.gg+DG[[TWW0gg+DG==

Q.

Q. DGTW
 ==a/a/ DGTW
 '',Q'',Q'')TYYq\'')TYYq\## X	 $ 
 	
r   )__name__
__module____qualname____doc__r   r   __annotations__r	   r
   r   r   r   r   r   r   r     r   r   r   r      sh    8 BNBNBNBNE3FCHcHc"
$ "
4 "
r   r   N)dataclassesr   moviepy.Clipr   moviepy.Effectr   r   r&   r   r   <module>r*      s,    !  ! H
6 H
 H
r   