While TexMobject treats LaTex formulas by default, TextMobject treats plain strings by default and only strings between $ and $ as LaTex formulas.
TextMobject class
object > Container > Mobject > VMobject > SVGMobject > SingleStringTexMobject > TexMobject > TextMobject
manimlib.mobject.svg.text_mobject.TextMobject(self, *tex_strings, **kwargs)
Make the tex_strings given as arguments an object that can be rendered by Manim.
Characters enclosed between $ in a given string are treated as LaTex expressions.
The TextMobject class inherits TexMobject and has the same constructor parameters.
Parameters: *text_string
text string to be converted to the object.
LaTex expression should be enclosed in '$'
Parameters: **kwargs
- stroke_width = 0: Text outline thickness. The default value is zero
- fill_opacity=1.0: Text color transparency. 1 is opaque, 0 is transparent
- height: Text's height
TextMobject is mainly used to represent plain strings without formulas.
Until the Text class came out, it was necessary to use the TextMobject for the expression of the general string.
However, since the Text class was created in the second half of 2019, if you use a later version of the Manim library, it is convenient to use the Text class.
The reason is that TextMobject inherits TexMobject, so all characters are converted to Tex, so rendering the corresponding Tex file is slow. On the other hand, Text inherits SVGMobject directly and does not generate Tex file, so rendering speed is fast.
Multilingual support
If you want to use a character other than English such as Korean character, refer to [02-4]Multilingual setting in LaText.
Text with a mixture of formulas and plain strings
The part of TextMobject that is wrapped with $ becomes a LaTex expression.
The example below is made with Text, TextMobject, and TexMobject as the default text string. You can see that TexMobject wraps the formula part with $, and in the case of TexMobject, you can see that LaTex expression is expressed without $.
str = Text("Fermat's Last Theorem ", font='Arial', stroke_widh=0)
text = TextMobject("no integers (a,b,c) satisfy $a^n+b^n=c^n$, where $n > 2$")
tex = TexMobject("x^n + y^n = z^n")
group = VGroup(str, text, tex)
group.arrange(DOWN)
self.add(group)
self.wait()
Next: [05-3]Shapes
Go To: [99] Table of Contents
'Programming > Manim Lectures' 카테고리의 다른 글
[05-3-A] Common Methods (0) | 2020.06.07 |
---|---|
[05-3]Shapes (0) | 2020.06.07 |
[05-2-B]TexMobject: for equation (0) | 2020.06.06 |
[05-2-A] Text: for general text string (0) | 2020.06.06 |
[05-2] Text, Equation (0) | 2020.06.06 |