
    ljE                    &   d Z ddlmZ g dZddlmZmZ ddlmZ ddl	m
Z
 ddlmZmZmZmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZmZmZ  G d de          Z  G d de           Z! G d de          Z" G d de          Z#dS )z2Mobjects used to mark and annotate other mobjects.    )annotations)SurroundingRectangleBackgroundRectangleCross	Underline)AnySelf)logger)config)DOWNLEFTRIGHT
SMALL_BUFFUP)Line)RoundedRectangle)Mobject)OpenGLMobject)VGroup)BLACKPURE_YELLOWREDParsableManimColorc                  .     e Zd ZdZeeddd fdZ xZS )r   a=  A rectangle surrounding a :class:`~.Mobject`

    Examples
    --------
    .. manim:: SurroundingRectExample
        :save_last_frame:

        class SurroundingRectExample(Scene):
            def construct(self):
                title = Title("A Quote from Newton")
                quote = Text(
                    "If I have seen further than others, \n"
                    "it is by standing upon the shoulders of giants.",
                    color=BLUE,
                ).scale(0.75)
                box = SurroundingRectangle(quote, color=YELLOW, buff=MED_LARGE_BUFF)

                t2 = Tex(r"Hello World").scale(1.5)
                box2 = SurroundingRectangle(t2, corner_radius=0.2)
                mobjects = VGroup(VGroup(box, quote), VGroup(t2, box2)).arrange(DOWN)
                self.add(title, mobjects)
    g        )colorbuffcorner_radiusmobjectsr   r   r   r   float | tuple[float, float]r   floatkwargsr   returnNonec               b   ddl m} t          d |D                       st          d          t	          |t
                    r|d         }|d         }n|x}} || }	 t                      j        d||	j        d|z  z   |	j	        d|z  z   |d| || _
        |                     |	           d S )	Nr   )Groupc              3  N   K   | ] }t          |t          t          f          V  !d S )N)
isinstancer   r   ).0mobs     `/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/mobject/geometry/shape_matchers.py	<genexpr>z0SurroundingRectangle.__init__.<locals>.<genexpr><   s1      QQ:cG]#;<<QQQQQQ    z;Expected all inputs for parameter mobjects to be a Mobjects      )r   widthheightr    )manim.mobject.mobjectr%   all	TypeErrorr'   tuplesuper__init__r/   r0   r   move_to)selfr   r   r   r   r!   r%   buff_xbuff_ygroup	__class__s             r*   r7   zSurroundingRectangle.__init__2   s     	0/////QQQQQQQ 	M   dE"" 	#!WF!WFF""FVx  	
+F
*<!f*,'		
 	

 	
 	
 	
 	Ur,   )r   r   r   r   r   r   r   r    r!   r   r"   r#   )__name__
__module____qualname____doc__r   r   r7   __classcell__r=   s   @r*   r   r      s\         4 %0,6"           r,   r   c                  F     e Zd ZdZddddddd fdZddZd fdZ xZS )r   a  A background rectangle. Its default color is the background color
    of the scene.

    Examples
    --------
    .. manim:: ExampleBackgroundRectangle
        :save_last_frame:

        class ExampleBackgroundRectangle(Scene):
            def construct(self):
                circle = Circle().shift(LEFT)
                circle.set_stroke(color=GREEN, width=20)
                triangle = Triangle().shift(2 * RIGHT)
                triangle.set_fill(PINK, opacity=0.5)
                backgroundRectangle1 = BackgroundRectangle(circle, color=WHITE, fill_opacity=0.15)
                backgroundRectangle2 = BackgroundRectangle(triangle, color=WHITE, fill_opacity=0.15)
                self.add(backgroundRectangle1)
                self.add(backgroundRectangle2)
                self.add(circle)
                self.add(triangle)
                self.play(Rotate(backgroundRectangle1, PI / 4))
                self.play(Rotate(backgroundRectangle2, PI / 2))
    Nr   g      ?r   stroke_widthstroke_opacityfill_opacityr   r   r   r   ParsableManimColor | NonerF   r    rG   rH   r   r   r!   r   r"   r#   c          	     z    |t           j        } t                      j        ||||||d| | j        | _        d S )NrE   )r   background_colorr6   r7   rH   original_fill_opacity)	r9   r   rF   rG   rH   r   r   r!   r=   s	           r*   r7   zBackgroundRectangle.__init__l   sa     =+E%)%	
 	
 	
 	
 	
 -1,="""r,   mobjectabr	   c                B    |                      || j        z             | S )N)opacity)set_fillrL   )r9   rM   rN   rO   s       r*   pointwise_become_partialz,BackgroundRectangle.pointwise_become_partial   s#    a$"<<===r,   c                    t                                          t          dt          |           t          |          dk    rt	          j        d|           | S )Nr   )stroke_colorrF   
fill_colorrH   z8Argument %s is ignored in BackgroundRectangle.set_style.)r6   	set_styler   lenr
   info)r9   rH   r!   r=   s      r*   rW   zBackgroundRectangle.set_style   sd     	%	 	 	
 	
 	
 v;;??KJ   r,   )r   r   r   rI   rF   r    rG   r    rH   r    r   r   r!   r   r"   r#   )rM   r   rN   r   rO   r    r"   r	   )rH   r    r!   r   r"   r	   )r>   r?   r@   rA   r7   rS   rW   rB   rC   s   @r*   r   r   S   s         6 ,0 !",-> > > > > > > >0            r,   r   c                  .     e Zd ZdZdeddfd fdZ xZS )r   ak  Creates a cross.

    Parameters
    ----------
    mobject
        The mobject linked to this instance. It fits the mobject when specified. Defaults to None.
    stroke_color
        Specifies the color of the cross lines. Defaults to RED.
    stroke_width
        Specifies the width of the cross lines. Defaults to 6.
    scale_factor
        Scales the cross to the provided units. Defaults to 1.

    Examples
    --------
    .. manim:: ExampleCross
        :save_last_frame:

        class ExampleCross(Scene):
            def construct(self):
                cross = Cross()
                self.add(cross)
    Ng      @g      ?rM   Mobject | NonerU   r   rF   r    scale_factorr!   r   r"   r#   c                h    t                      j        t          t          t          z   t
          t          z             t          t          t          z   t
          t          z             fi | ||                     |d           |                     |           | 	                    ||           d S )NT)stretch)r   r/   )
r6   r7   r   r   r   r   r   replacescale
set_stroke)r9   rM   rU   rF   r\   r!   r=   s         r*   r7   zCross.__init__   s     	dD5L))4U
D4K+H+H	
 	
LR	
 	
 	
 LL$L///

<   l,?????r,   )rM   r[   rU   r   rF   r    r\   r    r!   r   r"   r#   )r>   r?   r@   rA   r   r7   rB   rC   s   @r*   r   r      se         4 #'+.!!@ @ @ @ @ @ @ @ @ @ @r,   r   c                  (     e Zd ZdZefd fd
Z xZS )r   a8  Creates an underline.

    Examples
    --------
    .. manim:: UnderLine
        :save_last_frame:

        class UnderLine(Scene):
            def construct(self):
                man = Tex("Manim")  # Full Word
                ul = Underline(man)  # Underlining the word
                self.add(man, ul)
    rM   r   r   r    r!   r   r"   r#   c                     t                      j        t          t          fd|i| |                     |           |                     |t          | j                   d S )Nr   )r   )r6   r7   r   r   match_widthnext_tor   r   )r9   rM   r   r!   r=   s       r*   r7   zUnderline.__init__   s_     	u::4:6:::!!!Wd33333r,   )rM   r   r   r    r!   r   r"   r#   )r>   r?   r@   rA   r   r7   rB   rC   s   @r*   r   r      sQ          /94 4 4 4 4 4 4 4 4 4 4r,   r   N)$rA   
__future__r   __all__typingr   r	   manimr
   manim._configr   manim.constantsr   r   r   r   r   manim.mobject.geometry.liner   manim.mobject.geometry.polygramr   r2   r   #manim.mobject.opengl.opengl_mobjectr   &manim.mobject.types.vectorized_mobjectr   manim.utils.colorr   r   r   r   r   r   r   r   r1   r,   r*   <module>rq      s   8 8 " " " " " "
O
O
O                                        - , , , , , < < < < < < ) ) ) ) ) ) = = = = = = 9 9 9 9 9 9 I I I I I I I I I I I I6 6 6 6 6+ 6 6 6rC C C C C. C C CL'@ '@ '@ '@ '@F '@ '@ '@T4 4 4 4 4 4 4 4 4 4r,   