
    W|h
                     \    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)    )	dataclassN)Clip)Effect)	ImageClipc                       \ rS 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\4S jrS\S\4S jrSrg)Margin
   a  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  ^ ^^^ T R                   S:w  a.  TR                  c!  TR                  (       d  TR                  5       mT R                  b&  T R                  =T l        =T l        =T l        T l        UU 4S jm[        T[        5      (       a  T" TR                  TR                  5      mTR                  TT R                  T R                  TR                  -   2T R
                  T R
                  TR                  -   24'   TR                  U4S j5      $ UU 4S jnTR                  U5      $ )zAdd margins to the clip.r   c                   > U TR                   -   TR                  -   UTR                  -   TR                  -   p2TR                  (       aI  X24n[
        R                  " TR                  X245      R                  [        5      R                  U5      nU$ X2S4n[
        R                  " TR                  X245      R                  U5      nU$ )N   )r   r   r   r   is_masknptiler   astypefloatreshaper   )whnew_wnew_hshapebgr   selfs         Q/home/james-whalen/.local/lib/python3.13/site-packages/moviepy/video/fx/Margin.pymake_bg"Margin.add_margin.<locals>.make_bg8   s    tyy=4::5q488|dkk7Q5||WWT\\E>:AA%HPPQVW I q)WWTZZ%8@@GI    c                    > T$ )N )picims    r#   <lambda>#Margin.add_margin.<locals>.<lambda>E   s    Br&   c                    > U " U5      nUR                   S S u  p4T" XC5      nX%TR                  TR                  U-   2TR                  TR                  U-   24'   U$ )N   )r    r   r   )	get_frametr)   r   r   r*   r$   r"   s         r#   filter!Margin.add_margin.<locals>.filterI   sZ    lyy!}Q]IL488dhhl*DII		A,EEF	r&   )r   maskr   	with_maskr
   r   r   r   r   
isinstancer   r   r   imgimage_transform	transform)r"   r   r1   r*   r$   s   `` @@r#   
add_marginMargin.add_margin0   s    LLCdii&7$,,>>#D'>B>N>NNDIN
NTX	 dI&&(BOSxxBtxx$((TVV++TYYTVV9K-KKL''77 >>&))r&   returnc                     U R                  US9nUR                  (       a  U R                  UR                  S9Ul        U$ )zApply the effect to the clip.)r   )r9   r3   )r"   r   s     r#   applyMargin.applyR   s6     D)99TYY7DIr&   )r   r   r   r   )__name__
__module____qualname____firstlineno____doc__r
   int__annotations__r   r   r   r   r   tupler   r   r   r9   r=   __static_attributes__r(   r&   r#   r   r   
   sk    8 KD#ME3NCLFCOE5GU *t  *D$ 4 r&   r   )dataclassesr   numpyr   moviepy.Clipr   moviepy.Effectr   moviepy.video.VideoClipr   r   r(   r&   r#   <module>rM      s2    !   ! - OV O Or&   