
    lj^d                       d Z ddlmZ g dZddlZddlmZmZm	Z	 ddl
mZ ddlZerddlmZ ddlmZ dd	l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  ddl!m"Z"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z)m*Z*  G d de          Z+ G d de+          Z, G d de,          Z- G d de          Z. G d de.          Z/ G d d e/          Z0 G d! d"e          Z1 G d# d$e          Z2 G d% d&e2          Z3 G d' d(e3          Z4 G d) d*e2          Z5 G d+ d,e           Z6 G d- d.e3          Z7 G d/ d0e7          Z8dS )1a  Animate the display or removal of a mobject from a scene.

.. manim:: CreationModule
    :hide_source:

    from manim import ManimBanner
    class CreationModule(Scene):
        def construct(self):
            s1 = Square()
            s2 = Square()
            s3 = Square()
            s4 = Square()
            VGroup(s1, s2, s3, s4).set_x(0).arrange(buff=1.9).shift(UP)
            s5 = Square()
            s6 = Square()
            s7 = Square()
            VGroup(s5, s6, s7).set_x(0).arrange(buff=2.6).shift(2 * DOWN)
            t1 = Text("Write", font_size=24).next_to(s1, UP)
            t2 = Text("AddTextLetterByLetter", font_size=24).next_to(s2, UP)
            t3 = Text("Create", font_size=24).next_to(s3, UP)
            t4 = Text("Uncreate", font_size=24).next_to(s4, UP)
            t5 = Text("DrawBorderThenFill", font_size=24).next_to(s5, UP)
            t6 = Text("ShowIncreasingSubsets", font_size=22).next_to(s6, UP)
            t7 = Text("ShowSubmobjectsOneByOne", font_size=22).next_to(s7, UP)

            self.add(s1, s2, s3, s4, s5, s6, s7, t1, t2, t3, t4, t5, t6, t7)

            texts = [Text("manim", font_size=29), Text("manim", font_size=29)]
            texts[0].move_to(s1.get_center())
            texts[1].move_to(s2.get_center())
            self.add(*texts)

            objs = [ManimBanner().scale(0.25) for _ in range(5)]
            objs[0].move_to(s3.get_center())
            objs[1].move_to(s4.get_center())
            objs[2].move_to(s5.get_center())
            objs[3].move_to(s6.get_center())
            objs[4].move_to(s7.get_center())
            self.add(*objs)

            self.play(
                # text creation
                Write(texts[0]),
                AddTextLetterByLetter(texts[1]),
                # mobject creation
                Create(objs[0]),
                Uncreate(objs[1]),
                DrawBorderThenFill(objs[2]),
                ShowIncreasingSubsets(objs[3]),
                ShowSubmobjectsOneByOne(objs[4]),
                run_time=3,
            )

            self.wait()

    )annotations)CreateUncreateDrawBorderThenFillWriteUnwriteShowPartialShowIncreasingSubsetsSpiralInAddTextLetterByLetterRemoveTextLetterByLetterShowSubmobjectsOneByOneAddTextWordByWordTypeWithCursorUntypeWithCursorN)CallableIterableSequence)TYPE_CHECKING)Text)Scene)RIGHTTAU)OpenGLSurface)OpenGLVMobject)
ManimColor   )config)	Animation)
Succession)GroupMobject)VMobject)integer_interpolate)double_smoothlinearc                  4     e Zd ZdZd fdZddZddZ xZS )r	   a  Abstract class for Animations that show the VMobject partially.

    Raises
    ------
    :class:`TypeError`
        If ``mobject`` is not an instance of :class:`~.VMobject`.

    See Also
    --------
    :class:`Create`, :class:`~.ShowPassingFlash`

    mobject0VMobject | OpenGLVMobject | OpenGLSurface | Nonec                    t          |dd           }t          |          st          | j        j         d           t                      j        |fi | d S )Npointwise_become_partialz only works for VMobjects.)getattrcallable	TypeError	__class____name__super__init__)selfr(   kwargs	pointwiser/   s       S/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/animation/creation.pyr2   zShowPartial.__init__t   si    
 G%?FF		"" 	Tt~6RRRSSS++F+++++    
submobjectr"   starting_submobjectalphafloatreturnNonec                H     |j         |g|                     |          R   d S N)r+   _get_bounds)r3   r8   r9   r:   s       r6   interpolate_submobjectz"ShowPartial.interpolate_submobject~   sC     	,
+	
"&"2"25"9"9	
 	
 	
 	
 	
 	
r7   tuple[float, float]c                     t          d          )Nz%Please use Create or ShowPassingFlash)NotImplementedErrorr3   r:   s     r6   r@   zShowPartial._get_bounds   s    !"IJJJr7   )r(   r)   r8   r"   r9   r"   r:   r;   r<   r=   r:   r;   r<   rB   )r0   
__module____qualname____doc__r2   rA   r@   __classcell__r/   s   @r6   r	   r	   f   sw         , , , , , ,
 
 
 
K K K K K K K Kr7   r	   c                  2     e Zd ZdZ	 	 dd fdZddZ xZS )r   a  Incrementally show a VMobject.

    Parameters
    ----------
    mobject
        The VMobject to animate.

    Raises
    ------
    :class:`TypeError`
        If ``mobject`` is not an instance of :class:`~.VMobject`.

    Examples
    --------
    .. manim:: CreateScene

        class CreateScene(Scene):
            def construct(self):
                self.play(Create(Square()))

    See Also
    --------
    :class:`~.ShowPassingFlash`

          ?Tr(   )VMobject | OpenGLVMobject | OpenGLSurface	lag_ratior;   
introducerboolr<   r=   c                B     t                      j        |f||d| d S )N)rP   rQ   r1   r2   )r3   r(   rP   rQ   r4   r/   s        r6   r2   zCreate.__init__   s2     	WI*WWPVWWWWWr7   r:   rB   c                
    d|fS Nr    rE   s     r6   r@   zCreate._get_bounds   s    5zr7   )rN   T)r(   rO   rP   r;   rQ   rR   r<   r=   rG   )r0   rH   rI   rJ   r2   r@   rK   rL   s   @r6   r   r      so         : 	X X X X X X X       r7   r   c                  *     e Zd ZdZ	 	 dd fd
Z xZS )r   a  Like :class:`Create` but in reverse.

    Examples
    --------
    .. manim:: ShowUncreate

        class ShowUncreate(Scene):
            def construct(self):
                self.play(Uncreate(Square()))

    See Also
    --------
    :class:`Create`

    Tr(   VMobject | OpenGLVMobjectreverse_rate_functionrR   removerr<   r=   c                D     t                      j        |f|d|d| d S )NF)rZ   rQ   r[   rT   )r3   r(   rZ   r[   r4   r/   s        r6   r2   zUncreate.__init__   sJ     		
"7		
 	

 	
 	
 	
 	
 	
r7   )TT)r(   rY   rZ   rR   r[   rR   r<   r=   r0   rH   rI   rJ   r2   rK   rL   s   @r6   r   r      sT         & '+	
 
 
 
 
 
 
 
 
 
 
r7   r   c                  h     e Zd ZdZdedddfd fdZd dZd! fdZd"dZd#dZ	d$ fdZ
d%dZ xZS )&r   a  Draw the border first and then show the fill.

    Examples
    --------
    .. manim:: ShowDrawBorderThenFill

        class ShowDrawBorderThenFill(Scene):
            def construct(self):
                self.play(DrawBorderThenFill(Square(fill_opacity=1, fill_color=ORANGE)))
    r   NTvmobjectrY   run_timer;   	rate_funcCallable[[float], float]stroke_widthstroke_colorstrrQ   rR   r<   r=   c                    |                      |            t                      j        |f|||d| || _        || _        |                                 | _        d S )N)r`   rQ   ra   )_typecheck_inputr1   r2   rc   rd   get_outlineoutline)	r3   r_   r`   ra   rc   rd   rQ   r4   r/   s	           r6   r2   zDrawBorderThenFill.__init__   s}     	h'''	
!		
 	

 	
 	
 	
 )(''))r7   c                v    t          |t          t          f          st          | j        j         d          d S )Nz# only works for vectorized Mobjects)
isinstancer#   r   r.   r/   r0   r3   r_   s     r6   rg   z#DrawBorderThenFill._typecheck_input   sF    (X~$>?? 	>*OOO  	 	r7   c                z    |                                  | _        t                                                       d S r?   )rh   ri   r1   beginr3   r/   s    r6   rn   zDrawBorderThenFill.begin   s+    ''))r7   r"   c                    | j                                         }|                    d           |                                D ]1}|                    |                     |          | j                   2|S )Nr   opacity)colorwidth)r(   copyset_fillfamily_members_with_points
set_strokeget_stroke_colorrc   )r3   ri   sms      r6   rh   zDrawBorderThenFill.get_outline  sx    ,##%%###4466 	T 	TBMM 5 5b 9 9ARMSSSSr7   r   c                    | j         r| j         S |                                dk    r|                                S |                                S rV   )rd   get_stroke_widthry   	get_colorrl   s     r6   ry   z#DrawBorderThenFill.get_stroke_color  sQ     	/$$&&((1,,,,...!!###r7   Sequence[Mobject]c                V    g t                                                      | j        S r?   )r1   get_all_mobjectsri   ro   s    r6   r   z#DrawBorderThenFill.get_all_mobjects  s%    :))++:T\::r7   r8   r9   r:   c                    t          dd|          \  }}|dk    r.|                    |d|           |                    |           d S |                    |||           d S )Nr   r   )r$   r+   match_styleinterpolate)r3   r8   r9   ri   r:   indexsubalphas          r6   rA   z)DrawBorderThenFill.interpolate_submobject  ss     .aE::xA:://HEEE""7+++++""7,?JJJJJr7   )r_   rY   r`   r;   ra   rb   rc   r;   rd   re   rQ   rR   r<   r=   )r_   rY   r<   r=   r<   r=   )r<   r"   )r_   rY   r<   r   )r<   r~   rF   )r0   rH   rI   rJ   r%   r2   rg   rn   rh   ry   r   rA   rK   rL   s   @r6   r   r      s        	 	 .; * * * * * * *,           $ $ $ $; ; ; ; ; ;K K K K K K K Kr7   r   c                  R     e Zd ZdZedfd fdZddZddZd fdZd fdZ	 xZ
S )r   a  Simulate hand-writing a :class:`~.Text` or hand-drawing a :class:`~.VMobject`.

    Examples
    --------
    .. manim:: ShowWrite

        class ShowWrite(Scene):
            def construct(self):
                self.play(Write(Text("Hello", font_size=144)))

    .. manim:: ShowWriteReversed

        class ShowWriteReversed(Scene):
            def construct(self):
                self.play(Write(Text("Hello", font_size=144), reverse=True, remover=False))

    Tests
    -----

    Check that creating empty :class:`.Write` animations works::

        >>> from manim import Write, Text
        >>> Write(Text(''))
        Write(Text(''))
    Fr_   rY   ra   rb   reverserR   r<   r=   c                    |                     dd           }|                     dd           }|                     |||          \  }}|| _        d|vr||d<    t                      j        |f|||| d| d S )Nr`   rP   r[   )ra   r`   rP   rQ   )pop_set_default_config_from_lengthr   r1   r2   r3   r_   ra   r   r4   r`   rP   r/   s          r6   r2   zWrite.__init__>  s     "(J!=!="(**[$"?"?	"BB
 
)
 F"" 'F9	
"{	
 	
 	
 	
 	
 	
 	
r7   r`   float | NonerP   rB   c                    t          |                                          }|
|dk     rdnd}|!t          dt          d|          z  d          }||fS )N      r   g      @rN   g?)lenrw   minmax)r3   r_   r`   rP   lengths        r6   r   z%Write._set_default_config_from_lengthX  sc     X88::;;"RKKqqQHC#c6"2"22C88I""r7   c                <    | j                             d           d S )NT)	recursive)r(   invert)r3   s    r6   reverse_submobjectszWrite.reverse_submobjectse  s!    d+++++r7   c                ~    | j         r|                                  t                                                       d S r?   )r   r   r1   rn   ro   s    r6   rn   zWrite.beginh  s4    < 	'$$&&&r7   c                    t                                                       | j        r|                                  d S d S r?   )r1   finishr   r   ro   s    r6   r   zWrite.finishm  sC    < 	'$$&&&&&	' 	'r7   )r_   rY   ra   rb   r   rR   r<   r=   )r_   rY   r`   r   rP   r   r<   rB   r   )r0   rH   rI   rJ   r&   r2   r   r   rn   r   rK   rL   s   @r6   r   r   #  s         : /5	
 
 
 
 
 
 
4# # # #, , , ,     
' ' ' ' ' ' ' ' ' 'r7   r   c                  *     e Zd ZdZedfd fdZ xZS )r   a  Simulate erasing by hand a :class:`~.Text` or a :class:`~.VMobject`.

    Parameters
    ----------
    reverse
        Set True to have the animation start erasing from the last submobject first.

    Examples
    --------

    .. manim :: UnwriteReverseTrue

        class UnwriteReverseTrue(Scene):
            def construct(self):
                text = Tex("Alice and Bob").scale(3)
                self.add(text)
                self.play(Unwrite(text))

    .. manim:: UnwriteReverseFalse

        class UnwriteReverseFalse(Scene):
            def construct(self):
                text = Tex("Alice and Bob").scale(3)
                self.add(text)
                self.play(Unwrite(text, reverse=False))
    Tr_   r#   ra   rb   r   rR   r<   r=   c                    |                     dd           }|                     dd           }|                     |||          \  }} t                      j        |f||d|d| d S )Nr`   rP   T)r`   rP   rZ   r   )r   r   r1   r2   r   s          r6   r2   zUnwrite.__init__  s     "(J!=!="(**[$"?"?	"BB
 
)
 		
"&	
 	
 	
 	
 	
 	
 	
r7   )r_   r#   ra   rb   r   rR   r<   r=   )r0   rH   rI   rJ   r&   r2   rK   rL   s   @r6   r   r   s  sT         < /5	
 
 
 
 
 
 
 
 
 
 
r7   r   c                  2     e Zd ZdZ	 	 dd fd
ZddZ xZS )r   a"  Create the Mobject with sub-Mobjects flying in on spiral trajectories.

    Parameters
    ----------
    shapes
        The Mobject on which to be operated.

    scale_factor
        The factor used for scaling the effect.

    fade_in_fraction
        Fractional duration of initial fade-in of sub-Mobjects as they fly inward.

    Examples
    --------
    .. manim :: SpiralInExample

        class SpiralInExample(Scene):
            def construct(self):
                pi = MathTex(r"\pi").scale(7)
                pi.shift(2.25 * LEFT + 1.5 * UP)
                circle = Circle(color=GREEN_C, fill_opacity=1).shift(LEFT)
                square = Square(color=BLUE_D, fill_opacity=1).shift(UP)
                shapes = VGroup(pi, circle, square)
                self.play(SpiralIn(shapes))
       333333?shapesr"   scale_factorr;   r<   r=   c                   |                                 | _        || _        |                                | _        || _        |D ]m}|                                |_        |j        |j        | j        z
  | j        z  z   |_        |                    |j                   |	                                 n t                      j        |fddi| d S )NrQ   T)ru   r   r   
get_centershape_centerfade_in_fractionfinal_positioninitial_positionmove_to
save_stater1   r2   )r3   r   r   r   r4   shaper/   s         r6   r2   zSpiralIn.__init__  s     kkmm("--// 0 	 	E#(#3#3#5#5E $'$*;;t?PPQ " MM%0111;;D;F;;;;;r7   r:   c                   |                      |          }t          | j        | j        d          D ]\  }}|                                 |                                }|                                }t          |||z  | j        z            }t          |||z  | j        z            }|	                    |j
        |j        z
  |z             |                    t          |z  | j                   |                    t           |z  |                                           |                    |           |                    |           !d S )NT)strict)about_pointrq   )ra   zipr   r(   restoreget_fill_opacityget_stroke_opacityr   r   shiftr   r   rotater   r   get_center_of_massrv   rx   )r3   r:   original_shaper   fill_opacitystroke_opacitynew_fill_opacitynew_stroke_opacitys           r6   interpolate_mobjectzSpiralIn.interpolate_mobject  sR   u%%%(dl4%P%P%P 	9 	9!NEMMOOO)::<<L+>>@@N"el2T5JJ    "% 69N N" " KK-0FF%OPPPLLu$2CLDDDLL#53K3K3M3MLNNNNN#3N444%78888	9 	9r7   )r   r   )r   r"   r   r;   r<   r=   r:   r;   r<   r=   )r0   rH   rI   rJ   r2   r   rK   rL   s   @r6   r   r     sh         <  	< < < < < < <,9 9 9 9 9 9 9 9r7   r   c                  F     e Zd ZdZdej        dfd fdZddZddZ xZ	S )r
   a  Show one submobject at a time, leaving all previous ones displayed on screen.

    Examples
    --------

    .. manim:: ShowIncreasingSubsetsScene

        class ShowIncreasingSubsetsScene(Scene):
            def construct(self):
                p = VGroup(Dot(), Square(), Triangle())
                self.add(p)
                self.play(ShowIncreasingSubsets(p))
                self.wait()
    Fgroupr"   suspend_mobject_updatingrR   int_func"Callable[[np.ndarray], np.ndarray]r<   r=   c                    t          |j                  | _        || _        | j        D ]}|                    d            t                      j        |f||d| d S )Nr   )r   rZ   )listsubmobjectsall_submobsr   set_opacityr1   r2   )r3   r   r   r   rZ   r4   mobjr/   s          r6   r2   zShowIncreasingSubsets.__init__  s       122 $ 	  	 DQ	
%="7	
 	
 		
 	
 	
 	
 	
r7   r:   r;   c                
   t          | j                  }| j        rd|                     |          z
  n|                     |          }t	          |                     ||z                      }|                     |           d S )Nr   )r   r   rZ   ra   intr   update_submobject_list)r3   r:   	n_submobsvaluer   s        r6   r   z)ShowIncreasingSubsets.interpolate_mobject  s    ())	 )'Au%%%%&& 	
 DMM%)"34455##E*****r7   r   r   c                    | j         d |         D ]}|                    d           | j         |d          D ]}|                    d           d S Nr   r   )r   r   r3   r   r   s      r6   r   z,ShowIncreasingSubsets.update_submobject_list  sp    $VeV, 	  	 DQ$UVV, 	  	 DQ	  	 r7   )r   r"   r   rR   r   r   r<   r=   r   r   r   r<   r=   )
r0   rH   rI   rJ   npfloorr2   r   r   rK   rL   s   @r6   r
   r
     s         $ */79x#
 
 
 
 
 
 
&+ + + +               r7   r
   c                  >     e Zd ZdZdej        eddddfd fdZ xZS )r   a  Show a :class:`~.Text` letter by letter on the scene.

    Parameters
    ----------
    time_per_char
        Frequency of appearance of the letters.

    .. tip::

        This is currently only possible for class:`~.Text` and not for class:`~.MathTex`

    F皙?NTtextr   r   rR   r   r   ra   rb   time_per_charr;   r`   r   r<   r=   c	           
        || _         |                                st          d| d          |8t          j        dt
          j        z  | j         f          t          |          z  } t                      j	        |f||||||d|	 d S )NzThe text mobject z) does not seem to contain any characters.r   )r   r   ra   r`   rZ   rQ   )
r   rw   
ValueErrorr   r   r   
frame_rater   r1   r2   )r3   r   r   r   ra   r   r`   rZ   rQ   r4   r/   s             r6   r2   zAddTextLetterByLetter.__init__.  s     +..00 	SDSSS    vq6#44d6HIJJSQUYYVH		
%="7!		
 		
 		
 		
 		
 		
 		
r7   r   r   r   rR   r   r   ra   rb   r   r;   r`   r   r<   r=   	r0   rH   rI   rJ   r   ceilr&   r2   rK   rL   s   @r6   r   r      se           */79w.4"!%#
 
 
 
 
 
 
 
 
 
 
r7   r   c                  @     e Zd ZdZdej        edddddfd fdZ xZS )r   a  Remove a :class:`~.Text` letter by letter from the scene.

    Parameters
    ----------
    time_per_char
        Frequency of appearance of the letters.

    .. tip::

        This is currently only possible for class:`~.Text` and not for class:`~.MathTex`

    Fr   NTr   r   r   rR   r   r   ra   rb   r   r;   r`   r   r<   r=   c
                N     t                      j        |f||||||||	d|
 d S )N)r   r   ra   r   r`   rZ   rQ   r[   rT   )r3   r   r   r   ra   r   r`   rZ   rQ   r[   r4   r/   s              r6   r2   z!RemoveTextLetterByLetter.__init__^  sY     		
%='"7!	
 	
 	
 	
 	
 	
 	
r7   r   r   rL   s   @r6   r   r   P  sh           */79w.4"!%"
 
 
 
 
 
 
 
 
 
 
r7   r   c                  :     e Zd ZdZej        fd fdZddZ xZS )r   zRShow one submobject at a time, removing all previously displayed ones from screen.r   Iterable[Mobject]r   r   r<   r=   c                R    t          | } t                      j        |fd|i| d S )Nr   )r!   r1   r2   )r3   r   r   r4   	new_groupr/   s        r6   r2   z ShowSubmobjectsOneByOne.__init__|  s8     5M	@@X@@@@@@r7   r   r   c                    | j         d |         }|d d         D ]}|                    d           t          |          dk    r|d                             d           d S d S )Nr   r   )r   r   r   )r3   r   current_submobjectsr   s       r6   r   z.ShowSubmobjectsOneByOne.update_submobject_list  s~    ".vv6', 	  	 DQ"##a''#//22222 ('r7   )r   r   r   r   r<   r=   r   )	r0   rH   rI   rJ   r   r   r2   r   rK   rL   s   @r6   r   r   y  sj        \\
 8:wA A A A A A A3 3 3 3 3 3 3 3r7   r   c                  *     e Zd ZdZ	 	 dd fdZ xZS )r   zIShow a :class:`~.Text` word by word on the scene. Note: currently broken.NQ?text_mobjectr   r`   r;   r   r<   r=   c                    || _         | j         t          j        fd|D              } t                      j        |i | d S )Nc           	   3     K   | ]I}t          |t          |          z             t          |dt          |          dz  z             gV  JdS ))r`   g{Gzt?g      ?N)r
   r   r   ).0wordtpcs     r6   	<genexpr>z-AddTextWordByWord.__init__.<locals>.<genexpr>  su        
  *$s4yyIIIdUSYY#5E-EFFF     r7   )r   itchainr1   r2   )r3   r   r`   r   r4   animsr   r/   s         @r6   r2   zAddTextWordByWord.__init__  sn     +    
 )  
 	%*6*****r7   )Nr   )r   r   r`   r;   r   r;   r<   r=   r]   rL   s   @r6   r   r     sP        SS
 #	+ + + + + + + + + + +r7   r   c                  ^     e Zd ZdZ	 	 	 	 	 	 dd fdZd fdZd fdZd fdZddZ xZ	S )r   al  Similar to :class:`~.AddTextLetterByLetter` , but with an additional cursor mobject at the end.

    Parameters
    ----------
    time_per_char
        Frequency of appearance of the letters.
    cursor
        :class:`~.Mobject` shown after the last added letter.
    buff
        Controls how far away the cursor is to the right of the last added letter.
    keep_cursor_y
        If ``True``, the cursor's y-coordinate is set to the center of the ``Text`` and remains the same throughout the animation. Otherwise, it is set to the center of the last added letter.
    leave_cursor_on
        Whether to show the cursor after the animation.

    .. tip::
        This is currently only possible for class:`~.Text` and not for class:`~.MathTex`.


    Examples
    --------

    .. manim:: InsertingTextExample
        :ref_classes: Blink

        class InsertingTextExample(Scene):
            def construct(self):
                text = Text("Inserting", color=PURPLE).scale(1.5).to_edge(LEFT)
                cursor = Rectangle(
                    color = GREY_A,
                    fill_color = GREY_A,
                    fill_opacity = 1.0,
                    height = 1.1,
                    width = 0.5,
                ).move_to(text[0]) # Position the cursor

                self.play(TypeWithCursor(text, cursor))
                self.play(Blink(cursor, blinks=2))

    r   TFr   r   cursorr"   buffr;   keep_cursor_yrR   leave_cursor_onr   r<   r=   c	                |    || _         || _        || _        || _         t	                      j        |f|||d|	 d S )N)r   rZ   rQ   )r   r   r   r   r1   r2   )r3   r   r   r   r   r   r   rZ   rQ   r4   r/   s             r6   r2   zTypeWithCursor.__init__  sh     	*.	
'"7!		
 	

 	
 	
 	
 	
 	
r7   c                   | j                                         | _        | j                                        | j         _        | j        r| j                             | j                   | j                             d           | j        	                    | j                    t                                                       d S rV   )r   get_yy_cursorr(   r   r   r   set_yr   addr1   rn   ro   s    r6   rn   zTypeWithCursor.begin  s    ))++'+|'>'>'@'@$ 	-Kdm,,,"""%%%r7   c                    | j         r| j                            d           n9| j                            d           | j                            | j                   t                                                       d S r   )r   r   r   r(   remover1   r   ro   s    r6   r   zTypeWithCursor.finish  so     	-K##A&&&&K##A&&&L,,,r7   scener   c                    | j         s|                    | j                   t                                          |           d S r?   )r   r   r   r1   clean_up_from_scene)r3   r   r/   s     r6   r  z"TypeWithCursor.clean_up_from_scene  s@    # 	&LL%%%##E*****r7   r   r   c                p   | j         d |         D ]}|                    d           | j         |d          D ]}|                    d           |dk    rY| j                            | j         |dz
           t          | j                                      | j        j        d                    nH| j                            | j         d                                       | j        j        d                    | j	        r| j                            | j
                   | j                            d           d S )Nr   r   )r   )r   r   r   next_tor   r   r   r   r   r   r   r   s      r6   r   z%TypeWithCursor.update_submobject_list  s9   $VeV, 	  	 DQ$UVV, 	  	 DQA::K +U    eDK034444K 0 344::,Q/    	-Kdm,,,"""""r7   )r   TTr   FT)r   r   r   r"   r   r;   r   rR   r   rR   r   r;   r<   r=   r   )r   r   r<   r=   r   )
r0   rH   rI   rJ   r2   rn   r   r  r   rK   rL   s   @r6   r   r     s        ' 'Z " $"#
 
 
 
 
 
 
0          + + + + + +
# # # # # # # #r7   r   c                  0     e Zd ZdZ	 	 	 	 	 dd fdZ xZS )r   an  Similar to :class:`~.RemoveTextLetterByLetter` , but with an additional cursor mobject at the end.

    Parameters
    ----------
    time_per_char
        Frequency of appearance of the letters.
    cursor
        :class:`~.Mobject` shown after the last added letter.
    buff
        Controls how far away the cursor is to the right of the last added letter.
    keep_cursor_y
        If ``True``, the cursor's y-coordinate is set to the center of the ``Text`` and remains the same throughout the animation. Otherwise, it is set to the center of the last added letter.
    leave_cursor_on
        Whether to show the cursor after the animation.

    .. tip::
        This is currently only possible for class:`~.Text` and not for class:`~.MathTex`.


    Examples
    --------

    .. manim:: DeletingTextExample
        :ref_classes: Blink

        class DeletingTextExample(Scene):
            def construct(self):
                text = Text("Deleting", color=PURPLE).scale(1.5).to_edge(LEFT)
                cursor = Rectangle(
                    color = GREY_A,
                    fill_color = GREY_A,
                    fill_opacity = 1.0,
                    height = 1.1,
                    width = 0.5,
                ).move_to(text[0]) # Position the cursor

                self.play(UntypeWithCursor(text, cursor))
                self.play(Blink(cursor, blinks=2))

    Nr   TFr   r   r   VMobject | Noner   r;   r<   r=   c           	     H     t                      j        |f|||||d| d S )N)r   r   rZ   rQ   r[   rT   )	r3   r   r   r   rZ   rQ   r[   r4   r/   s	           r6   r2   zUntypeWithCursor.__init__>  sP     		
'"7!	
 	
 	
 	
 	
 	
 	
r7   )Nr   TFT)r   r   r   r  r   r;   r<   r=   r]   rL   s   @r6   r   r     s^        ' 'X #'""
 
 
 
 
 
 
 
 
 
 
r7   r   )9rJ   
__future__r   __all__	itertoolsr   collections.abcr   r   r   typingr   numpyr   manim.mobject.text.text_mobjectr   manim.scene.scener   manim.constantsr   r   #manim.mobject.opengl.opengl_surfacer   .manim.mobject.opengl.opengl_vectorized_mobjectr   manim.utils.colorr    r   animation.animationr   animation.compositionr    mobject.mobjectr!   r"    mobject.types.vectorized_mobjectr#   utils.bezierr$   utils.rate_functionsr%   r&   r	   r   r   r   r   r   r   r
   r   r   r   r   r   r   rW   r7   r6   <module>r     s  7 7r # " " " " "  $     8 8 8 8 8 8 8 8 8 8                 (444444'''''' & & & & & & & & = = = = = = I I I I I I ( ( ( ( ( (       + + + + + + . . . . . . , , , , , , , , 7 7 7 7 7 7 . . . . . . 8 8 8 8 8 8 8 8#K #K #K #K #K) #K #K #KL% % % % %[ % % %P
 
 
 
 
v 
 
 
BKK KK KK KK KK KK KK KK\M' M' M' M' M' M' M' M'`1
 1
 1
 1
 1
e 1
 1
 1
hB9 B9 B9 B9 B9y B9 B9 B9J1  1  1  1  1 I 1  1  1 h-
 -
 -
 -
 -
1 -
 -
 -
`&
 &
 &
 &
 &
4 &
 &
 &
R3 3 3 3 33 3 3 3*+ + + + +
 + + +0k# k# k# k# k#* k# k# k#\<
 <
 <
 <
 <
~ <
 <
 <
 <
 <
r7   