Ë
    Eü´j÷'  ã                   óF   — d Z ddlZ	 	 	 	 	 	 	 dd„Z	 	 	 	 	 	 	 	 dd„Zdd„Zy)	zDeals with making images (np arrays). It provides drawing
methods that are difficult to do with the existing Python libraries.
é    Nc	                 óÊ  — | \  }	}
t        j                  |«      j                  t        «      }t        j                  |«      j                  t        «      }|dk(  rº|€8|€t	        d«      ‚t        j                  |«      t        j                  |«      z
  }||D �cg c]  }| ‘Œ c}fD �cg c]  }t        | ||ddd|¬«      ‘Œ c}\  }}t        j                  ||«      }|j                  dkD  rt        j                  d	|gz  «      }||z  d|z
  |z  z   S t        j                  |ddd
…   «      j                  t        «      }t        j                  t        j                  t        |	«      t        |
«      «      ddd
…   «      j                  t        «      }|dk(  rò|€,|�t        j                  |ddd
…   «      |z
  }n&t	        d«      ‚t        j                  |ddd
…   «      }t         j                  j                  |«      }||dz  z  }|||z  z   }||z
  j                  |«      d|z
  z  }t        j                  dt        j                  d|«      «      }|j                  dkD  rt        j                  d	|gz  «      }||z  d|z
  |z  z   S |dk(  r½|xs ddk(  rt        j                  |
|	f«      }nft        j                   ||z
  dz  j#                  d¬«      «      ||z  z
  }|d|z
  |z  z  }t        j                  dt        j                  d|«      «      }|j                  dkD  rt        j                  d	|gz  «      }d|z
  |z  ||z  z   S t	        d«      ‚c c}w c c}w )aq  Draw a linear, bilinear, or radial gradient.

    The result is a picture of size ``size``, whose color varies
    gradually from color `color_1` in position ``p1`` to color ``color_2``
    in position ``p2``.

    If it is a RGB picture the result must be transformed into
    a 'uint8' array to be displayed normally:

    Parameters
    ----------

    size : tuple or list
        Size (width, height) in pixels of the final image array.

    p1 : tuple or list
       Position for the first coordinate of the gradient in pixels (x, y).
       The color 'before' ``p1`` is ``color_1`` and it gradually changes in
       the direction of ``p2`` until it is ``color_2`` when it reaches ``p2``.

    p2 : tuple or list, optional
       Position for the second coordinate of the gradient in pixels (x, y).
        Coordinates (x, y)  of the limit point for ``color_1``
        and ``color_2``.

    vector : tuple or list, optional
        A vector (x, y) in pixels that can be provided instead of ``p2``.
        ``p2`` is then defined as (p1 + vector).

    color_1 : tuple or list, optional
        Starting color for the gradient. As default, black. Either floats
        between 0 and 1 (for gradients used in masks) or [R, G, B] arrays
        (for colored gradients).

    color_2 : tuple or list, optional
        Color for the second point in the gradient. As default, white. Either
        floats between 0 and 1 (for gradients used in masks) or [R, G, B]
        arrays (for colored gradients).

    shape : str, optional
        Shape of the gradient. Can be either ``"linear"``, ``"bilinear"`` or
        ``"circular"``. In a linear gradient the color varies in one direction,
        from point ``p1`` to point ``p2``. In a bilinear gradient it also
        varies symmetrically from ``p1`` in the other direction. In a circular
        gradient it goes from ``color_1`` to ``color_2`` in all directions.

    radius : float, optional
        If ``shape="radial"``, the radius of the gradient is defined with the
        parameter ``radius``, in pixels.

    offset : float, optional
        Real number between 0 and 1 indicating the fraction of the vector
        at which the gradient actually starts. For instance if ``offset``
        is 0.9 in a gradient going from p1 to p2, then the gradient will
        only occur near p2 (before that everything is of color ``color_1``)
        If the offset is 0.9 in a radial gradient, the gradient will
        occur in the region located between 90% and 100% of the radius,
        this creates a blurry disc of radius ``d(p1, p2)``.

    Returns
    -------

    image
        An Numpy array of dimensions (width, height, n_colors) of type float
        representing the image of the gradient.

    Examples
    --------

    .. code:: python

        color_gradient((10, 1), (0, 0), p2=(10, 0))  # from white to black
        #[[1.  0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1]]
        # from red to green
        color_gradient(
            (10, 1), (0, 0),
            p2=(10, 0),
            color_1=(255, 0, 0),
            color_2=(0, 255, 0)
        )
        # [[[  0.  255.    0. ]
        #   [ 25.5 229.5   0. ]
        #   [ 51.  204.    0. ]
        #   [ 76.5 178.5   0. ]
        #   [102.  153.    0. ]
        #   [127.5 127.5   0. ]
        #   [153.  102.    0. ]
        #   [178.5  76.5   0. ]
        #   [204.   51.    0. ]
        #   [229.5  25.5   0. ]]]
    ÚbilinearNz(You must provide either 'p2' or 'vector'ç      ð?ç        Úlinear)ÚvectorÚcolor_1Úcolor_2ÚshapeÚoffseté   é   éÿÿÿÿé   r   Úradial)Úaxisz@Invalid shape, should be either 'radial', 'linear' or 'bilinear')ÚnpÚarrayÚastypeÚfloatÚ
ValueErrorÚcolor_gradientÚmaximumÚsizeÚdstackÚmeshgridÚrangeÚlinalgÚnormÚdotÚminimumÚonesÚsqrtÚsum)r   Úp1Úp2r   Úradiusr	   r
   r   r   ÚwÚhÚvÚm1Úm2ÚarrÚMr   Ún_vecs                     úY/root/workspace/ytshorts/venv/lib/python3.12/site-packages/moviepy/video/tools/drawing.pyr   r      s  € ðN �D€A€qä�h‰h�wÓ×&Ñ&¤uÓ-€GÜ�h‰h�wÓ×&Ñ&¤uÓ-€Gà�
ÒØˆ>ØˆzÜ Ð!KÓLÐLÜ—X‘X˜b“\¤B§H¡H¨R£LÑ0ˆFð ¨6Ö2 a šrÒ2Ð3ö
ð ô ØØØØØØØöò
‰ˆˆBô �j‰j˜˜RÓ ˆØ�<‰<˜!ÒÜ—)‘)˜A  ™IÓ&ˆCØ�W‰}  C¡¨7Ñ2Ñ2Ð2ä	�‰�"‘T�r�T‘(Ó	×	"Ñ	"¤5Ó	)€Bä
�	‰	”"—+‘+œe A›h¬¨a«Ó1±$°B°$Ñ7Ó8×?Ñ?ÄÓF€Aà�ÒØˆ>Øˆ~ÜŸ™ "¡T r T¡(Ó+¨bÑ0‘ä Ð!KÓLÐLä—X‘X˜f¡T r T™lÓ+ˆFä�y‰y�~‰~˜fÓ%ˆØ˜˜q™Ñ ˆà�&˜6‘/Ñ!ˆØ�2‰v�l‰l˜5Ó! Q¨¡ZÑ0ˆÜ�j‰j˜œBŸJ™J q¨#Ó.Ó/ˆØ�<‰<˜!ÒÜ—)‘)˜A  ™IÓ&ˆCØ�W‰}  C¡¨7Ñ2Ñ2Ð2à	�(Ò	ØŠK�a˜AÒÜ—'‘'˜1˜a˜&“/‰Cä—7‘7˜Q ™V¨™M×.Ñ.°AÐ.Ó6Ó7¸6ÀF¹?ÑJˆCØ˜!˜f™*¨Ñ.Ñ/ˆCÜ—*‘*˜S¤"§*¡*¨Q°Ó"4Ó5ˆCà�<‰<˜!ÒÜ—)‘)˜A  ™IÓ&ˆCØ�C‘˜7Ñ" S¨7¡]Ñ2Ð2Ü
ÐWÓ
XÐXùòU 3ùò
s   Â
MÂ*M c	                 óÚ  — |s|€ÿ|€ý|�,t        j                  |«      t        j                  |«      z
  }na|�/t        j                  ddg«      }t        j                  |dg«      }n0|�.t        j                  ddg«      }t        j                  d|g«      }|\  }}t        j                  || g«      j                  d«      }t         j                  j	                  |«      }	t        d|«      |z  |	z  }t        | ||||d¬	«      S | \  }
}t        j                  |«      r||
fn||
t        |«      f}t        j                  |«      }|r||dd…d|…f<   ||dd…|d…f<   |S |r
||d| |||d |S )
aƒ  Make an image split in 2 colored regions.

    Returns an array of size ``size`` divided in two regions called 1 and
    2 in what follows, and which will have colors color_1 and color_2
    respectively.

    Parameters
    ----------

    x : int, optional
        If provided, the image is split horizontally in x, the left
        region being region 1.

    y : int, optional
        If provided, the image is split vertically in y, the top region
        being region 1.

    p1, p2: tuple or list, optional
        Positions (x1, y1), (x2, y2) in pixels, where the numbers can be
        floats. Region 1 is defined as the whole region on the left when
        going from ``p1`` to ``p2``.

    p1, vector: tuple or list, optional
        ``p1`` is (x1,y1) and vector (v1,v2), where the numbers can be
        floats. Region 1 is then the region on the left when starting
        in position ``p1`` and going in the direction given by ``vector``.

    gradient_width : float, optional
        If not zero, the split is not sharp, but gradual over a region of
        width ``gradient_width`` (in pixels). This is preferable in many
        situations (for instance for antialiasing).

    Examples
    --------

    .. code:: python

        size = [200, 200]

        # an image with all pixels with x<50 =0, the others =1
        color_split(size, x=50, color_1=0, color_2=1)

        # an image with all pixels with y<50 red, the others green
        color_split(size, x=50, color_1=[255, 0, 0], color_2=[0, 255, 0])

        # An image split along an arbitrary line (see below)
        color_split(size, p1=[20, 50], p2=[25, 70], color_1=0, color_2=1)
    Nr   g      ð¿r   r   r   gš™™™™™¹?r   )r   r	   r
   r   )
r   r   r   r   r   Úmaxr   ÚisscalarÚlenÚzeros)r   ÚxÚyr%   r&   r   r	   r
   Úgradient_widthr   r(   r)   r   r-   s                 r0   Úcolor_splitr9   ±   sn  € ñv ˜1˜9¨1¨9Øˆ>Ü—X‘X˜b“\¤B§H¡H¨R£LÑ0‰FØˆ]Ü—X‘X˜q $˜iÓ(ˆFÜ—‘˜1˜a˜&Ó!‰BØˆ]Ü—X‘X˜s C˜jÓ)ˆFÜ—‘˜1˜a˜&Ó!ˆBà‰ˆˆ1Ü—‘˜1˜q˜b˜'Ó"×)Ñ)¨'Ó2ˆÜ�y‰y�~‰~˜fÓ%ˆÜ�S˜.Ó)¨FÑ2°TÑ9ˆÜØ�"˜V¨W¸gÈXô
ð 	
ð ‰ˆˆ1ÜŸ+™+ gÔ.��A‘°Q¸¼3¸w»<Ð4HˆÜ�h‰h�u‹oˆÙØ ˆC’�2�A�2�‰JØ ˆC’�1‘2�‰Jð ˆ
ñ ØˆC��ˆGØˆC��ˆGØˆ
ó    c           	      óD   — |rd||z
  z  |z  nd}t        | ||||d|¬«      S )aþ  Draw an image with a circle.

    Draws a circle of color ``color``, on a background of color ``bg_color``,
    on a screen of size ``screensize`` at the position ``center=(x, y)``,
    with a radius ``radius`` but slightly blurred on the border by ``blur``
    pixels.

    Parameters
    ----------

    screensize : tuple or list
        Size of the canvas.

    center : tuple or list
        Center of the circle.

    radius : float
        Radius of the circle, in pixels.

    bg_color : tuple or float, optional
        Color for the background of the canvas. As default, black.

    blur : float, optional
        Blur for the border of the circle.

    Examples
    --------

    .. code:: python

        from moviepy.video.tools.drawing import circle

        circle(
            (5, 5),  # size
            (2, 2),  # center
            2,      # radius
        )
        # array([[0.        , 0.        , 0.        , 0.        , 0.        ],
        #        [0.        , 0.58578644, 1.        , 0.58578644, 0.        ],
        #        [0.        , 1.        , 1.        , 1.        , 0.        ],
        #        [0.        , 0.58578644, 1.        , 0.58578644, 0.        ],
        #        [0.        , 0.        , 0.        , 0.        , 0.        ]])
    r   r   r   )r%   r'   r	   r
   r   r   )r   )Ú
screensizeÚcenterr'   ÚcolorÚbg_colorÚblurr   s          r0   ÚcirclerA   
  s>   € ñX 06ˆS�F˜T‘MÑ" VÒ+¸1€FÜØØØØØØØôð r:   )NNNr   r   r   r   )NNNNNr   r   r   )r   r   r   )Ú__doc__Únumpyr   r   r9   rA   © r:   r0   ú<module>rE      sT   ðñó ð ØØØØØ
ØófYðV Ø
ØØØØØØóVôr5r:   