
    -i
                     j    d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	 e G d de                      Z
dS )    )	dataclassN)Clip)Effect)	ImageClipc                       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efdZdedefdZdS )MarginaK  Draws an external margin all around the frame.

    Parameters
    ----------

    margin_size : int, optional
      If not ``None``, then the new clip has a margin size of
      size ``margin_size`` in pixels on the left, right, top, and bottom.

    left : int, optional
      If ``margin_size=None``, margin size for the new clip in left direction.

    right : int, optional
      If ``margin_size=None``, margin size for the new clip in right direction.

    top : int, optional
      If ``margin_size=None``, margin size for the new clip in top direction.

    bottom : int, optional
      If ``margin_size=None``, margin size for the new clip in bottom direction.

    color : tuple, optional
      Color of the margin.

    opacity : float, optional
      Opacity of the margin. Setting this value to 0 yields transparent margins.
    Nmargin_sizer   leftrighttopbottom)r   r   r   color      ?opacityclipc                      j         dk    r"j        j        s                                 j        ! j        x _        x _        x _         _         fdt          t                    rb j        j                  j         j         j        j        z    j         j        j        z   f<                       fd          S  fd}                    |          S )zAdd margins to the clip.r   Nc                 ^   | j         z   j        z   |j        z   j        z   }}j        rL||f}t          j        j        ||f                              t                    
                    |          }n4||df}t          j        j        ||f          
                    |          }|S )N   )r
   r   r   r   is_masknptiler   astypefloatreshaper   )whnew_wnew_hshapebgr   selfs         U/var/www/html/speakWrite/venv/lib/python3.11/site-packages/moviepy/video/fx/Margin.pymake_bgz"Margin.add_margin.<locals>.make_bg8   s    ty=4:5q48|dk7Q5E| HWT\E5>::AA%HHPPQVWWq)WTZ%88@@GGI    c                     S )N )picims    r"   <lambda>z#Margin.add_margin.<locals>.<lambda>E   s    B r$   c                      | |          }|j         d d         \  }} ||          }||j        j        |z   j        j        |z   f<   |S )N   )r   r   r
   )	get_frametr'   r   r   r(   r#   r!   s         r"   filterz!Margin.add_margin.<locals>.filterI   s`    illy!}1WQ]]IL48dhl*DI	A,EEF	r$   )r   maskr   	with_maskr	   r
   r   r   r   
isinstancer   r   r   imgimage_transform	transform)r!   r   r.   r(   r#   s   `` @@r"   
add_marginzMargin.add_margin0   s   LCdi&7$,&7>>##D'>B>NNDIN
NTX	 	 	 	 	 	 dI&& 	*((BOSxBtx$(TV++TYTV9K-KKL''777      >>&)))r$   returnc                     |                      |          }|j        r |                      |j                  |_        |S )zApply the effect to the clip.)r   )r5   r/   )r!   r   s     r"   applyzMargin.applyR   s=     D))9 	8TY77DIr$   )__name__
__module____qualname____doc__r	   int__annotations__r
   r   r   r   r   tupler   r   r   r5   r8   r&   r$   r"   r   r   
   s          8 KD#MMME3NNNCLLLFCOOOE5GU *t  *  *  *  *D$ 4      r$   r   )dataclassesr   numpyr   moviepy.Clipr   moviepy.Effectr   moviepy.video.VideoClipr   r   r&   r$   r"   <module>rE      s    ! ! ! ! ! !           ! ! ! ! ! ! - - - - - - O O O O OV O O O O Or$   