
    lj-h                       d Z ddlmZ ddlmZmZ g dZddlZddl	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mZ ddlT 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Z$ G d de          Z% G d de%          Z& G d dee#          Z' G d de&          Z( G d de(          Z) G d d e(          Z*dS )!a;  Mobjects representing text rendered using LaTeX.

.. important::

   See the corresponding tutorial :ref:`rendering-with-latex`

.. note::

   Just as you can use :class:`~.Text` (from the module :mod:`~.text_mobject`) to add text to your videos, you can use :class:`~.Tex` and :class:`~.MathTex` to insert LaTeX.

    )annotations)BLACKParsableManimColor)SingleStringMathTexMathTexTexBulletedListTitleN)Iterable)reduce)dedent)AnySelf)configlogger)*)Line)
SVGMobject)VGroupVMobject)TexTemplate)tex_to_svg_file   )ConvertToOpenGL	substringc                       e Zd ZdZddddddedfd) fdZd*dZed+d            Zej	        d,d            Zd-d Z
d.d"Zd.d#Zd/d%Zd*d&Zd0d1d(Z xZS )2r   zElementary building block for rendering text with LaTeX.

    Tests
    -----
    Check that creating a :class:`~.SingleStringMathTex` object works::

        >>> SingleStringMathTex('Test') # doctest: +SKIP
        SingleStringMathTex('Test')
    r   TNFalign*
tex_stringstrstroke_widthfloatshould_centerboolheightfloat | Noneorganize_left_to_righttex_environment
str | Nonetex_templateTexTemplate | None	font_sizecolorParsableManimColor | Nonekwargsr   c
                   |	t                      j        }	|| _        || _        || _        |t
          d         }|| _        || _        t          | 	                    |          | j        | j                  } t                      j        d|||||	dddd|
 |                                  | j        | _        || j        | _        | j        r|                                  d S d S )Nr)   )environmentr)   T)should_subdivide_sharp_curvesshould_remove_null_curves)	file_namer"   r    r$   r,   path_string_config )r   r,   
_font_sizer&   r'   r   r)   r   r   _get_modified_expressionsuper__init__init_colorsr$   initial_heightr+   #_organize_submobjects_left_to_right)selfr   r    r"   r$   r&   r'   r)   r+   r,   r.   r3   	__class__s               Y/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/mobject/text/tex_mobject.pyr9   zSingleStringMathTex.__init__9   s(    =JJ$E#&<#.!.1L)5$#))*55,*
 
 
	
 	 	
'%15-1   	
 	
 	
 	
 	
 	 #k>!_DN& 	74466666	7 	7    returnc                Z    t          |           j         dt          | j                   dS N()type__name__reprr   r=   s    r?   __repr__zSingleStringMathTex.__repr__m   ,    t**%@@T_(=(=@@@@r@   c                0    | j         | j        z  t          z  S )z!The font size of the tex mobject.)r$   r;   SCALE_FACTOR_PER_FONT_POINTrJ   s    r?   r+   zSingleStringMathTex.font_sizep   s     {T003NNNr@   font_valNonec                    |dk    rt          d          | j        dk    r|                     || j        z             d S d S )Nr   z!font_size must be greater than 0.)
ValueErrorr$   scaler+   )r=   rO   s     r?   r+   zSingleStringMathTex.font_sizeu   sM    q==@AAA[1__ JJx$.011111 _r@   c                \    |}|                                 }|                     |          }|S N)strip_modify_special_strings)r=   r   results      r?   r7   z,SingleStringMathTex._get_modified_expression   s,    --f55r@   texc                p                                    t          t          j        dk    dk    dk    dk                        d                              d                              d          g          }|rd}|z  d	k    rd
dk    rd
                    d          r                    dd          fddD             \  }}||k    r,                    dd                              dd          |                               dD ]}d|z  v }d|z  v }||z  rdS )Nz\overz	\overlinez\sqrtz\sqrt{_^dotz{\quad}z	\substackz\quad \\z\quad\\c              3     K   | ]8}t          d                      |          dd         D                       V  9dS )c                *    g | ]}||d          dv |S )r   z	(){}[]|.\r5   .0ss     r?   
<listcomp>zISingleStringMathTex._modify_special_strings.<locals>.<genexpr>.<listcomp>   s+    PPPqQP1Q4<;O;O;O;O;Or@      N)lensplit)rc   substrrY   s     r?   	<genexpr>z>SingleStringMathTex._modify_special_strings.<locals>.<genexpr>   sc       !
 !
 PPCIIf--abb1PPPQQ!
 !
 !
 !
 !
 !
r@   )\left\rightrk   z\bigrl   )arrayz
\begin{%s}z\end{%s})rV   r   opor_endswith
startswithreplace_remove_stray_braces)	r=   rY   should_add_fillerfiller	num_lefts
num_rightscontextbegin_inend_ins	    `       r?   rW   z+SingleStringMathTex._modify_special_strings   s   iikk"F x|#xy S!!S!!U##
 
   	F6MC,C"99C >>&!! 	4++fl33C!
 !
 !
 !
/!
 !
 !
	: 
""++h00C++i11C'',,  	 	G%/C7H!G+3F&   
r@   c                b   |                     d          |                     d          z
  |                     d          z   }|                     d          |                     d          z
  |                     d          z   }||k    rd|z   }|dz  }||k    ||k    r|dz   }|dz  }||k    |S )z
        Makes :class:`~.MathTex` resilient to unmatched braces.

        This is important when the braces in the TeX code are spread over
        multiple arguments as in, e.g., ``MathTex(r"e^{i", r"\tau} = 1")``.
        {z\{z\\{}z\}z\\}rf   )count)r=   rY   rv   rw   s       r?   rs   z(SingleStringMathTex._remove_stray_braces   s     IIcNNSYYu%5%55		'8J8JJ	YYs^^cii&6&6679K9KK
9$$)CNI 9$$ *$$)C!OJ *$$ 
r@   r   c                2    |                      d            | S )Nc                    | d         S )Nr   r5   )ps    r?   <lambda>zISingleStringMathTex._organize_submobjects_left_to_right.<locals>.<lambda>   s
    AaD r@   )sortrJ   s    r?   r<   z7SingleStringMathTex._organize_submobjects_left_to_right   s    		..!!!r@   c                    | j         S rU   )r   rJ   s    r?   get_tex_stringz"SingleStringMathTex.get_tex_string   s
    r@   propagate_colorsc                   | j         D ]~}|j        t          k    r| j        |_        t          j        t
          j        k    r|                                 Nt          j        t
          j        k    r|                    |           | S )N)r   )	submobjectsr,   r   r   rendererRendererTypeOPENGLr:   CAIRO)r=   r   
submobjects      r?   r:   zSingleStringMathTex.init_colors   s    * 		J 		JJ 5((#zJ,"555&&((((L$666&&8H&IIIr@   )r   r   r    r!   r"   r#   r$   r%   r&   r#   r'   r(   r)   r*   r+   r!   r,   r-   r.   r   rA   r   )rA   r!   )rO   r!   rA   rP   )r   r   rA   r   )rY   r   rA   r   rA   r   )T)r   r#   rA   r   )rH   
__module____qualname____doc__DEFAULT_FONT_SIZEr9   rK   propertyr+   setterr7   rW   rs   r<   r   r:   __classcell__r>   s   @r?   r   r   .   sE          "#',&.+/,+/27 27 27 27 27 27 27hA A A A O O O XO 	2 	2 	2 	2   3 3 3 3j   $              r@   r   c                       e Zd ZdZdddddd: fdZd;dZed<d            Zd=dZd>dZ	d?d!Z
ed@d#            Zed@d$            ZdAd&ZdBd)ZdCd,Z	 	 dDdEd2ZdFd5ZdGd7ZdHd9Z xZS )Ir   uc  A string compiled with LaTeX in math mode.

    Examples
    --------
    .. manim:: Formula
        :save_last_frame:

        class Formula(Scene):
            def construct(self):
                t = MathTex(r"\int_a^b f'(x) dx = f(b)- f(a)")
                self.add(t)

    Notes
    -----
    Double-brace notation ``{{ ... }}`` can be used to split a single
    string argument into multiple submobjects without having to pass
    separate strings::

        MathTex(r"{{ a^2 }} + {{ b^2 }} = {{ c^2 }}")

    Each ``{{ ... }}`` group and every piece of text between groups
    becomes its own submobject, which is useful for
    :class:`~.TransformMatchingTex` animations.

    For ``{{`` to be recognised as a group opener it must appear either
    at the very start of the string or be immediately preceded by a
    whitespace character.  ``{{`` that follows non-whitespace — such as
    in ``\frac{{{n}}}{k}`` or ``a^{{2}}`` — is left untouched, so
    ordinary nested-brace LaTeX is not accidentally split.  To prevent
    an unintentional split, insert a space between the two braces:
    ``{{ ... }}`` → ``{ { ... } }``.

    Tests
    -----
    Check that creating a :class:`~.MathTex` works::

        >>> MathTex('a^2 + b^2 = c^2') # doctest: +SKIP
        MathTex('a^2 + b^2 = c^2')

    Check that double brace group splitting works correctly::

        >>> t1 = MathTex('{{ a }} + {{ b }} = {{ c }}') # doctest: +SKIP
        >>> len(t1.submobjects) # doctest: +SKIP
        5
        >>> t2 = MathTex(r"\frac{1}{a+b\sqrt{2}}") # doctest: +SKIP
        >>> len(t2.submobjects) # doctest: +SKIP
        1

     Nr   )arg_separatorsubstrings_to_isolatetex_to_color_mapr'   tex_stringsr   r   r   Iterable[str] | Noner   $dict[str, ParsableManimColor] | Noner'   r(   r.   r   c               \   |                     dt          d                   | _        || _        |g nt	          |          | _        |i | _        n|| _        | j                            | j                                                   || _	        d| _
        |                     |          | _        g | _        	 |                     | j        | j                  } t                      j        |f| j	        | j        d| | j                            | j                  | _        |                                  n<# t(          $ r/}| j
        r!t+          j        t/          d                     |d }~ww xY w|                     | j                   | j        r|                                  d S d S )Nr)   F)r'   r)   a                          A group of double braces, {{ ... }}, was detected in
                        your string. Manim splits TeX strings at the double
                        braces, which might have caused the current
                        compilation error. If you didn't use the double brace
                        split intentionally, add spaces between the braces to
                        avoid the automatic splitting: {{ ... }} --> { { ... } }.
                        )popr   r)   r   listr   r   extendkeysr'   brace_notation_split_occurred_prepare_tex_stringsr   matched_strings_and_ids)_join_tex_strings_with_unique_delimintersr8   r9   joinr   _break_up_by_substringsrR   r   errorr   set_color_by_tex_to_color_mapr&   r<   )
r=   r   r   r   r'   r   r.   joined_stringcompilation_errorr>   s
            r?   r9   zMathTex.__init__  s    #JJ~vn7MNN*'/BBT:O5P5P 	" #CED!!$4D!"))$*?*D*D*F*FGGG.-2*44[AA>@$	$ JJ $"< M EGG $ 4!.  	   #055d6FGGDO((**** 	$ 	$ 	$1 	 	   $#	$ 	**4+@AAA& 	74466666	7 	7s   9A?D9 9
E2*E--E2Iterable[str]rA   	list[str]c                    d |D             }g }|D ],}|                      |          }|                    |           -t          |          t          |          k    rd| _        d |D             S )Nc                Z    g | ](}t          |t                    r|nt          |          )S r5   )
isinstancer   rc   strings     r?   re   z0MathTex._prepare_tex_strings.<locals>.<listcomp>R  s>     !
 !
 !
CIj-->FF3v;;!
 !
 !
r@   Tc                8    g | ]}t          |          d k    |S )r   )rg   r   s     r?   re   z0MathTex._prepare_tex_strings.<locals>.<listcomp>\  s$    RRR6#f++PQ/////r@   )_split_double_bracesr   rg   r   )r=   r   tex_strings_validatedtex_strings_validated_twor   rh   s         r?   r   zMathTex._prepare_tex_stringsO  s    !
 !
MX!
 !
 !
 %'!/ 	4 	4J--j99E%,,U3333())C0E,F,FFF15D.RR%>RRRRr@   r   c                *   g }d}d}d}d}|t          |           k     r_| |         dk    rA|dz   t          |           k     r+| |dz            }|dk    s|dv r|| ||dz            z  }|dz  }a|sf| ||dz            dk    rD|dk    s| |dz
                                           r!|                    |           d}d	}d}|dz  }n|| |         z  }|dz  }n| |         d
k    r|dz  }|| |         z  }|dz  }nt| |         dk    r6|dk    r0| ||dz            dk    r|                    |           d}d}|dz  }n2| |         dk    r|dz  }|| |         z  }|dz  }n|| |         z  }|dz  }|t          |           k     _|                    |           |S )ab  Split *tex_string* on Manim's ``{{ ... }}`` double-brace notation.

        Rules that avoid false positives on ordinary LaTeX source:

        * ``{{`` is only treated as a group opener when it appears at the very
          start of the string or is immediately preceded by a whitespace
          character.  Naturally-occurring ``{{`` in LaTeX is usually preceded
          by non-whitespace (e.g. ``\frac{{{n}}}{k}`` or ``a^{{2}}``), so
          the whitespace guard eliminates the most common false positives
          without any brace-depth bookkeeping on the outer string.

        * Inside an open group the depth of *real* LaTeX braces is tracked.
          ``}}`` only closes the Manim group when the inner depth is zero,
          so ``{{ a^{b^{c}} }}`` is handled correctly.

        * Escape sequences are consumed as two-character units in priority
          order: ``\\`` first (escaped backslash), then ``\{`` / ``\}``
          (escaped braces).  This ensures e.g. ``\\}}`` is read as an
          escaped backslash followed by a real ``}}`` rather than as
          ``\`` + ``\}`` + lone ``}``.
        r^   r   F\rf   z{}r   z{{Tr|   r}   z}})rg   isspaceappend)r   segmentscurrentiinside_maniminner_depthnext_chs          r?   r   zMathTex._split_double_braces^  s    . !#j//!!!}$$QZ)@)@$QU+d??goo z!a!e)44GFA "a!a%i(D00FFjQ/7799FOOG,,, G#'L"#KFAAz!},GFAAa=C''1$Kz!},GFAAqMS((#q(("1q1u9-55 OOG,,, G#(LFAA]c))1$Kz!},GFAAz!},GFA[ #j//!!^ 	   r@   c                   d}d}t          |          D ]\  }}d|dd}| j                            |d|df           t          |          }d}	t	          |          dk    rV|                     ||          }
|
r$|                     ||
          \  }}|	|z   }	|dz  }n|	|z   }	d}t	          |          dk    V||	z  }|t	          |          dz
  k     r
|| j        z  }|dz  }||z   }|S )	Nr^   r   "\special{dvisvgm:raw <g id='unique03d'>}uniquerf   \special{dvisvgm:raw </g>})	enumerater   r   r   rg   _locate_first_match_handle_matchr   )r=   r   r   r   ssIdxidxr   string_partunprocessed_stringprocessed_stringfirst_match	processeds               r?   r   z1MathTex._join_tex_strings_with_unique_deliminters  s`    (55 	8 	8OCNNNNNK(//=Oc=O=O=O0PQQQ
 "%Z!())A--"66)+=   ,484F4F{5 51I1 (8)'C$QJEE'7:L'L$)+& ())A-- ++KS%%)))t1188K)K7MMr@   r   re.Match | Nonec                   t          |          }d}d }|D ]1}t          j        dt          j        |           d|          }|rmt          |                    d                    |k     rG|}t          |                    d                    }t          |                    d                    }|rt          |                    d                    |k    rl|t          |                    d                    k     rF|}t          |                    d                    }t          |                    d                    }3|S )Nr   z(.*?)(z)(.*)rf   r   )rg   rematchescapegroup)r=   r   r   first_match_startfirst_match_lengthr   r   r   s           r?   r   zMathTex._locate_first_match  s0      233. 	= 	=IHAbi	&:&:AAACUVVE 	=U[[^^,,/@@@#$'A$7$7!%(Q%8%8"" =3u{{1~~..2CCC%EKKNN(;(;;;"'K(+EKKNN(;(;%),U[[^^)<)<&r@   r   intr   re.Matchtuple[str, str]c                   |                     d          }|                     d          }|                     d          }d|dt           d}d}| j                            |d|dt           f           ||z   |z   |z   }|}	||	fS )	Nrf   r      r   r   r   r   r   )r   MATHTEX_SUBSTRINGr   r   )
r=   r   r   	pre_matchmatched_string
post_match
pre_stringpost_stringr   r   s
             r?   r   zMathTex._handle_match  s    %%a((	$**1-- &&q))
U5UU>OUUU 	 4$++DeDD1BDDE	
 	
 	
 %z1NB[P'!333r@   list[tuple[str, str]]c                $    d | j         D             S )z4Return only the 'ss' (substring_to_isolate) matches.c                P    g | ]#\  }}|                     t                    ||f$S r5   rp   r   rc   rY   id_s      r?   re   z.MathTex._substring_matches.<locals>.<listcomp>  sC     
 
 
S||-..
#J
 
 
r@   r   rJ   s    r?   _substring_matcheszMathTex._substring_matches  &    
 
 8
 
 
 	
r@   c                $    d | j         D             S )z(Return only the main tex_string matches.c                P    g | ]#\  }}|                     t                    ||f$S r5   r   r   s      r?   re   z)MathTex._main_matches.<locals>.<listcomp>   sC     
 
 
S<< 122
#J
 
 
r@   r   rJ   s    r?   _main_matcheszMathTex._main_matches  r   r@   r   c                T   g }	 | j         D ]I\  }}t                      }||_         |j        | j        |         j          |                    |           JnK# t          $ r> t          j	        d| d| d           |                    | j        d                    Y nw xY w|| _        | S )z
        Reorganize existing submobjects one layer
        deeper based on the structure of tex_strings (as a list
        of tex_strings)
        z0MathTex: Could not find SVG group for tex part 'z' (id: z ). Using fallback to root group.root)
r   MathTexPartr   addid_to_vgroup_dictr   r   KeyErrorr   r   )r=   new_submobjectsr   tex_string_idmtps        r?   r   zMathTex._break_up_by_substrings  s     +-
	C-1-? , ,)
M!mm!+/>JKK&&s++++	,
  	C 	C 	CL F:  F  FVc  F  F  F   ""4#9&#ABBBBB		C
 +s   AA ABBrY   VGroup | Nonec                J    | j         D ]\  }}||k    r| j        |         c S d S rU   )r   r   )r=   rY   r.   tex_strmatch_ids        r?   get_part_by_texzMathTex.get_part_by_tex  s@    !%!= 	8 	8GX#~~-h7777 tr@   r,   r   c                l    | j         D ]+\  }}||k    r | j        |                             |           ,| S rU   )r   r   	set_color)r=   rY   r,   r.   r   r   s         r?   set_color_by_texzMathTex.set_color_by_tex!  sH     "&!= 	B 	BGX#~~&x0::5AAAr@         ?opacityr!   remaining_opacityr%   c                    ||                      |           | j        D ]+\  }}||k    r | j        |                              |           ,| S )a  
        Sets the opacity of the tex specified. If 'remaining_opacity' is specified,
        then the remaining tex will be set to that opacity.

        Parameters
        ----------
        tex
            The tex to set the opacity of.
        opacity
            Default 0.5. The opacity to set the tex to
        remaining_opacity
            Default None. The opacity to set the remaining tex to.
            If None, then the remaining tex will not be changed
        Nr  )set_opacityr   r   )r=   rY   r  r  r.   r   r   s          r?   set_opacity_by_texzMathTex.set_opacity_by_tex)  sf    * (%6777!%!= 	F 	FGX#~~&x0<<WEEEr@   texs_to_color_mapdict[str, ParsableManimColor]c                    t          |                                          D ]A\  }}| j        D ]4}|d         |k    r&| j        |d                                      |           5B| S )Nr   rf   )r   itemsr   r   r  )r=   r  r.   texsr,   r   s         r?   r   z%MathTex.set_color_by_tex_to_color_mapE  s       1 7 7 9 9:: 	F 	FKD%5 F F8t##*584>>uEEEF r@   partc                z    |                                  }||vrt          d          |                    |          S )Nz*Trying to get index of part not in MathTex)rh   rR   index)r=   r  
split_selfs      r?   index_of_partzMathTex.index_of_partN  s=    ZZ\\
z!!IJJJ%%%r@   rP   c                >    | j                             d            d S )Nc                *    |                                  S rU   )r   )ms    r?   r   z-MathTex.sort_alphabetically.<locals>.<lambda>U  s    A,<,<,>,> r@   )key)r   r   rJ   s    r?   sort_alphabeticallyzMathTex.sort_alphabeticallyT  s&    ">">?????r@   )r   r   r   r   r   r   r   r   r'   r(   r.   r   )r   r   rA   r   )r   r   rA   r   )r   r   r   r   rA   r   )r   r   r   r   rA   r   )r   r   r   r   rA   r   )rA   r   r   )rY   r   r.   r   rA   r   )rY   r   r,   r   r.   r   rA   r   )r  N)
rY   r   r  r!   r  r%   r.   r   rA   r   )r  r  r.   r   rA   r   )r  r   rA   r   )rA   rP   )rH   r   r   r   r9   r   staticmethodr   r   r   r   r   r   r   r   r   r  r
  r   r  r  r   r   s   @r?   r   r      s       0 0j !6:AE&.77 77 77 77 77 77 77 77rS S S S L L L \L\" " " "H   (4 4 4 4 
 
 
 X
 
 
 
 X
   *       *.	    8   & & & &@ @ @ @ @ @ @ @r@   r   c                  "    e Zd ZU ded<   ddZdS )r   r   r   rA   c                Z    t          |           j         dt          | j                   dS rC   rF   rJ   s    r?   rK   zMathTexPart.__repr__[  rL   r@   Nr   )rH   r   r   __annotations__rK   r5   r@   r?   r   r   X  s9         OOOA A A A A Ar@   r   )	metaclassc                  ,     e Zd ZdZdddd fdZ xZS )r   a  A string compiled with LaTeX in normal mode.

    The color can be set using
    the ``color`` argument. Any parts of the ``tex_string`` that are colored by the
    TeX commands ``\color`` or ``\textcolor`` will retain their original color.

    Tests
    -----

    Check whether writing a LaTeX string works::

        >>> Tex('The horse does not eat cucumber salad.') # doctest: +SKIP
        Tex('The horse does not eat cucumber salad.')

    r^   centerr   r'   r   r   r   r'   r(   r.   r   c               @     t                      j        |||d| d S )Nr!  )r8   r9   )r=   r   r'   r   r.   r>   s        r?   r9   zTex.__init__p  sB     	'+	
 	
 		
 	
 	
 	
 	
r@   )r   r   r   r   r'   r(   r.   r   )rH   r   r   r   r9   r   r   s   @r?   r   r   _  sY         &  &.	
 
 
 
 
 
 
 
 
 
 
 
r@   r   c                  8     e Zd ZdZedddd fdZdddZ xZS )r	   a  A bulleted list.

    Examples
    --------

    .. manim:: BulletedListExample
        :save_last_frame:

        class BulletedListExample(Scene):
            def construct(self):
                blist = BulletedList("Item 1", "Item 2", "Item 3", height=2, width=2)
                blist.set_color_by_tex("Item 1", RED)
                blist.set_color_by_tex("Item 2", GREEN)
                blist.set_color_by_tex("Item 3", BLUE)
                self.add(blist)
    r   N)buffdot_scale_factorr'   r  r   r$  r!   r%  r'   r(   r.   r   c                  || _         || _        || _        d |D             } t                      j        |d|i| | D ]e}t          d                              | j                  }|                    |d         t          t                     |
                    |           f|                     t          t          | j                    d S )Nc                    g | ]}|d z   S )r_   r5   rb   s     r?   re   z)BulletedList.__init__.<locals>.<listcomp>  s    :::qF
:::r@   r'   z\cdotr   )aligned_edger$  )r$  r%  r'   r8   r9   r   rS   next_toLEFT
SMALL_BUFFadd_to_backarrangeDOWN)
r=   r$  r%  r'   r  r.   line_separated_itemsr  r]   r>   s
            r?   r9   zBulletedList.__init__  s     	 0.::E:::!	
+	
 	
 	
 	

  	" 	"D(##))$*?@@CKKQz222S!!!!T49=====r@   r  index_or_string	int | strr  rA   rP   c                j   |}t          |t                    r+|                     |          }|t          d| d          n5t          |t                    r| j        |         }nt          d|           | j        D ]3}||u r|                    d           |                    |           4d S )Nz.Could not locate part by provided tex string 'z'.zExpected int or string, got rf   r  )r   r   r   	Exceptionr   r   	TypeErrorset_fill)r=   r0  r  argr  
other_parts         r?   fade_all_butzBulletedList.fade_all_but  s    c3 		B-1-A-A#-F-FD|LSLLL    S!! 	B#C(DD@3@@AAA* 	5 	5JT!!##A#....##G#4444		5 	5r@   )
r  r   r$  r!   r%  r!   r'   r(   r.   r   )r  )r0  r1  r  r!   rA   rP   )rH   r   r   r   MED_LARGE_BUFFr9   r8  r   r   s   @r?   r	   r	     su         ( %"#&*> > > > > > > >.5 5 5 5 5 5 5 5 5r@   r	   c                  .     e Zd ZdZddedd fdZ xZS )r
   ap  A mobject representing an underlined title.

    Examples
    --------
    .. manim:: TitleExample
        :save_last_frame:

        import manim

        class TitleExample(Scene):
            def construct(self):
                banner = ManimBanner()
                title = Title(f"Manim version {manim.__version__}")
                self.add(banner, title)

    TF)include_underlinematch_underline_width_to_textunderline_buff
text_partsr   r;  r#   r<  r=  r!   r.   r   c                  || _         || _        || _         t                      j        |i | |                     t                     | j         rt          d         dz
  }t          t          t                    }|                    | t          | j                   | j        r|                    |            n||_        |                     |           || _        d S d S )Nframe_widthr   )r$  )r;  r<  r=  r8   r9   to_edgeUPr   r   r*  RIGHTr)  r.  match_widthwidthr   	underline)	r=   r;  r<  r=  r>  r.   underline_widthrF  r>   s	           r?   r9   zTitle.__init__  s     "3-J*,*////R! 		'$]3a7OT5))IdDt/BCCC1 2%%d++++"1	HHY&DNNN		' 		'r@   )
r>  r   r;  r#   r<  r#   r=  r!   r.   r   )rH   r   r   r   MED_SMALL_BUFFr9   r   r   s   @r?   r
   r
     s\         ( #'.3 .' ' ' ' ' ' ' ' ' ' ' 'r@   r
   )+r   
__future__r   manim.utils.colorr   r   __all__operatorrn   r   collections.abcr   	functoolsr   textwrapr   typingr   r   manimr   r   manim.constantsmanim.mobject.geometry.liner   manim.mobject.svg.svg_mobjectr   &manim.mobject.types.vectorized_mobjectr   r   manim.utils.texr   manim.utils.tex_file_writingr   opengl.opengl_compatibilityr   r   r   r   r   r   r	   r
   r5   r@   r?   <module>rY     s  
 
 # " " " " " 7 7 7 7 7 7 7 7       				 $ $ $ $ $ $                                         , , , , , , 4 4 4 4 4 4 C C C C C C C C ' ' ' ' ' ' 8 8 8 8 8 8 9 9 9 9 9 9 r r r r r* r r rjr@ r@ r@ r@ r@! r@ r@ r@jA A A A A(o A A A A
 
 
 
 
' 
 
 
@95 95 95 95 953 95 95 95x(' (' (' (' ('C (' (' (' (' ('r@   