电脑配置:
Mac mini
Apple M2 Pro
内存: 16GB
Sonoma 14.6.1
Python: 3.10.11
我在网上找了好多教程,在电脑上装了manimgl。我也一同学习了用manimgl制作动画。
但是在写代码的时候,我遇到了一点小问题,以下是代码:
from manimlib import *
FILL_COLOR = BLUE_E
FILL_OPACITY = 0.5
class ManimScene(Scene):
def construct(self):
square = Polygon(np.array([-1, 2, 0]), np.array([-5, 2, 0]), np.array([-5, -2, 0]), np.array([-1, -2, 0]))
self.play(GrowFromCenter(square))
square_1 = Polygon(np.array([-3, 2, 0]), np.array([-3, -2, 0]), np.array([-5, -2, 0]), np.array([-5, 2, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_1))
square_2 = Polygon(np.array([-3, 0, 0]), np.array([-3, -2, 0]), np.array([-1, -2, 0]), np.array([-1, 0, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_2))
square_3 = Polygon(np.array([-3, 2, 0]), np.array([-3, 0, 0]), np.array([-2, 0, 0]), np.array([-2, 2, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_3))
square_4 = Polygon(np.array([-2, 0, 0]), np.array([-1, 0, 0]), np.array([-1, 1, 0]), np.array([-2, 1, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_4))
square_5 = Polygon(np.array([-2, 1, 0]), np.array([-1.5, 1, 0]), np.array([-1.5, 2, 0]), np.array([-2, 2, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_5))
square_6 = Polygon(np.array([-1.5, 1, 0]), np.array([-1, 1, 0]), np.array([-1, 1.5, 0]), np.array([-1.5, 1.5, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_6))
square_7 = Polygon(np.array([-1.5, 1.5, 0]), np.array([-1.25, 1.5, 0]), np.array([-1.25, 2, 0]), np.array([-1.5, 2, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_7))
square_8 = Polygon(np.array([-1.25, 1.5, 0]), np.array([-1, 1.5, 0]), np.array([-1, 1.75, 0]), np.array([-1.25, 1.75, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_8))
square_9 = Polygon(np.array([-1.25, 1.75, 0]), np.array([-1.125, 1.75, 0]), np.array([-1.125, 2, 0]), np.array([-1.25, 2, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_9))
square_10 = Polygon(np.array([-1.125, 1.875, 0]), np.array([-1, 1.875, 0]), np.array([-1, 1.75, 0]), np.array([-1.125, 1.75, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_10))
square_11 = Polygon(np.array([-1.125, 2, 0]), np.array([-1.0625, 2, 0]), np.array([-1.0625, 1.875, 0]), np.array([-1.125, 1.875, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_11))
square_12 = Polygon(np.array([-1.0625, 1.9375, 0]), np.array([-1.0625, 1.875, 0]), np.array([-1, 1.875, 0]), np.array([-1, 1.9375, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_12))
square_13 = Polygon(np.array([-1.0625, 2, 0]), np.array([-1.0625, 1.9375, 0]), np.array([-1.03125, 1.9375, 0]), np.array([-1.03125, 2, 0]), fill_color=FILL_COLOR, fill_opacity=FILL_OPACITY)
self.play(GrowFromCenter(square_13))
text = TexText("$\frac{1}{3}$")
text.move_to(RIGHT)
self.play(GrowFromCenter(text))
if __name__ == "__main__":
from os import system
system("manimgl {} ManimScene".format(__file__))
错误信息:
显示:Missing $ inserted.
应该是
text = TexText("$\frac{1}{3}$")
这句话出了问题。
我在网上搜索了LaTeX公式的语法,但是感觉代码没什么问题。
望各位能帮我解决一下,谢谢!