Ë
    Eü´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
y)é    )Ú	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y)Ú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                 óF  ‡ ‡‡‡— ‰ j                   dk7  r(‰j                  €‰j                  s‰j                  «       Š‰ j                  �&‰ j                  x‰ _        x‰ _        x‰ _        ‰ _        ˆˆ fd„Št        ‰t        «      rˆ ‰‰j                  ‰j                  «      Š‰j                  ‰‰ j                  ‰ j                  ‰j                  z   …‰ j
                  ‰ j
                  ‰j                  z   …f<   ‰j                  ˆfd„«      S ˆˆ fd„}‰j                  |«      S )zAdd margins to the clip.r   c                 ó�  •— | ‰j                   z   ‰j                  z   |‰j                  z   ‰j                  z   }}‰j                  rJ||f}t        j                  ‰j                  ||f«      j                  t        «      j                  |«      }|S ||df}t        j                  ‰j                  ||f«      j                  |«      }|S )Né   )r
   r   r   r   Úis_maskÚnpÚtiler   ÚastypeÚfloatÚreshaper   )ÚwÚhÚnew_wÚnew_hÚshapeÚbgr   Úselfs         €€úU/root/workspace/ytshorts/venv/lib/python3.12/site-packages/moviepy/video/fx/Margin.pyÚmake_bgz"Margin.add_margin.<locals>.make_bg8   sª   ø€ Ø˜tŸy™y™=¨4¯:©:Ñ5°q¸4¿8¹8±|ÀdÇkÁkÑ7Q�5ˆEØ�|Š|Ø ˜�Ü—W‘W˜TŸ\™\¨E°5¨>Ó:×AÑAÄ%ÓH×PÑPÐQVÓW�ð ˆIð   qÐ)�Ü—W‘W˜TŸZ™Z¨%°¨Ó8×@Ñ@ÀÓ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`   ø€ Ù “l�Ø—y‘y  !�}‘��1Ù˜Q “]�ØIL��4—8‘8˜dŸh™h¨™lÐ*¨D¯I©I¸¿	¹	À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ã   û€ à�L‰L˜CÒ d§i¡iÐ&7À$Ç,Â,Ø—>‘>Ó#ˆDà×ÑÐ'Ø>B×>NÑ>NÐNˆDŒIÐN˜œ
ÐN T¤X°´õ	ô �dœIÔ&Ù˜Ÿ™ §¡Ó(ˆBØOSÏxÉxˆBˆt�x‰x˜$Ÿ(™( T§V¡VÑ+Ð+¨T¯Y©Y¸¿¹ÀTÇVÁVÑ9KÐ-KÐKÑLØ×'Ñ'«Ó7Ð7õð —>‘> &Ó)Ð)r$   Úreturnc                 ó„   — | j                  |¬«      }|j                  r!| j                  |j                  ¬«      |_        |S )zApply the effect to the clip.)r   )r5   r/   )r!   r   s     r"   ÚapplyzMargin.applyR   s6   € ð �‰ DˆÓ)ˆà�9Š9ØŸ™¨T¯Y©Y˜Ó7ˆDŒIàˆr$   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   ÚintÚ__annotations__r
   r   r   r   r   Útupler   r   r   r5   r8   r&   r$   r"   r   r   
   sk   … ñð8 €K�ÓØ€Dˆ#ƒMØ€Eˆ3ƒNØ€CˆƒLØ€FˆCƒOØ€Eˆ5ÓØ€GˆUÓð *˜tó  *ðD˜$ð  4ô r$   r   )Údataclassesr   Únumpyr   Úmoviepy.Clipr   Úmoviepy.Effectr   Úmoviepy.video.VideoClipr   r   r&   r$   r"   ú<module>rE      s2   ðÝ !ã å Ý !Ý -ð ôOˆVó Oó ñOr$   