如何将内联形状插入 Manim Mathtex Mobject?

问题描述 投票:0回答:1

在 Manim 中,我使用 MathTex 来显示方程。 我想允许方程中的变量是我用其他 Manim 函数构造的形状。 不仅仅是圆形或方形,还可能是使用 VGroup 由多个形状组成的复合形状。 那么方程就会出现,但在方程中的相关位置我会看到形状。

latex inline equation tex manim
1个回答
0
投票

我在 Discord 上回答了你的问题 - 只是复制我认为你在这里要求的内容:

class visualMath(Scene):
    def construct(self):
        math = MathTex(*r"\text{Red Circle}  +  \text{Green Square}  =  \text{Blue Square}".split("  "))
        redCircle = Circle(color=RED).scale_to_fit_width(math[0].width).move_to(math[0].get_center())        
        greenSquare = Square(color=GREEN).scale_to_fit_width(math[2].width).move_to(math[2].get_center())
        blueSquare = Square(color=BLUE).scale_to_fit_width(math[4].width).move_to(math[4].get_center()) 

        vis = VGroup(redCircle,math[1].copy(),greenSquare,math[3].copy(),blueSquare)
        self.play(Write(vis))       
        self.wait()
        self.play(ReplacementTransform(vis,math))
        self.wait()

© www.soinside.com 2019 - 2024. All rights reserved.