文本与数学¶
影片代码
import manimgx as m
class TextAndMathHero(m.Scene):
def construct(self) -> None:
title = m.Text("The Pythagorean theorem", font_size=56)
formula = m.MathTex("a^2", "+", "b^2", "=", "c^2", font_size=80)
formula[2].set_color(m.YELLOW)
number = m.DecimalNumber(
3.14159, num_decimal_places=4, font_size=56, color=m.BLUE
)
lines = m.VGroup(title, formula, number).arrange(m.DOWN, buff=0.7)
self.play(m.Write(title))
self.play(m.Write(formula))
self.play(m.FadeIn(number))
self.wait()
ManimGX 自行排版文本与公式,使用 Typst 及其内置字体:你无需安装 LaTeX 和字体,且文本在每台计算机上看起来都一样。文本是由其字形组成的 mobject,因此它可以 像任何图形一样移动、缩放、着色和制作动画。
用 Text 书写文字,用 MathTex 书写 LaTeX 公式,用 Tex 书写含公式的文字,用 Typst 书写 Typst 标记。会变化的 数字是 DecimalNumber。


