数学公式

限定名称: manim.mobject.text.tex\_mobject.MathTex

class MathTex(*tex_strings, arg_separator=' ', substrings_to_isolate=None, tex_to_color_map=None, tex_environment='align*', **kwargs)[来源]

基础类:SingleStringMathTex

一个用LaTeX在数学模式下编译的字符串。

示例

示例:公式

../_images/Formula-1.png
from manim import *

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

测试

检查创建MathTex是否有效:

>>> MathTex('a^2 + b^2 = c^2') 
MathTex('a^2 + b^2 = c^2')

检查双大括号组分割是否正常工作:

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

方法

get_part_by_tex

get_parts_by_tex

index_of_part

index_of_part_by_tex

set_color_by_tex

set_color_by_tex_to_color_map

set_opacity_by_tex

设置指定文本的不透明度。

sort_alphabetically

属性

animate

用于动画化self的任何方法的应用。

animation_overrides

color

depth

mobject的深度。

fill_color

如果有多种颜色(用于渐变),则返回第一个颜色

font_size

tex mobject 的字体大小。

hash_seed

表示生成的mobject点结果的唯一哈希值。

height

mobject的高度。

n_points_per_curve

sheen_factor

stroke_color

width

mobject的宽度。

Parameters:
  • arg_separator (str)

  • substrings_to_isolate (可迭代[字符串] | )

  • tex_to_color_map (dict[str, ManimColor])

  • tex_environment (str)

_break_up_by_substrings()[来源]

根据tex_strings的结构(作为tex_strings的列表),将现有的子对象重新组织到更深的一层。

_original__init__(*tex_strings, arg_separator=' ', substrings_to_isolate=None, tex_to_color_map=None, tex_environment='align*', **kwargs)

初始化自身。有关准确的签名,请参阅 help(type(self))。

Parameters:
  • arg_separator (str)

  • substrings_to_isolate (可迭代[字符串] | )

  • tex_to_color_map (dict[str, ManimColor])

  • tex_environment (str)

set_opacity_by_tex(tex, opacity=0.5, remaining_opacity=None, **kwargs)[来源]

设置指定文本的不透明度。如果指定了‘remaining_opacity’,则剩余文本将设置为该不透明度。

Parameters:
  • tex (str) – 设置不透明度的tex。

  • opacity (float) – 默认值为0.5。设置文本的不透明度

  • remaining_opacity (float) – 默认值为 None。设置剩余文本的不透明度。 如果为 None,则剩余文本将不会更改