Search code examples
pythonanimationtextmanim

Manim Text does not bilink. The error i get is "'c^' is not a recognized color"


class FlashAnimationEffect(Scene):
    def construct(self):
        tex= Text("E","=","m","c^","2").scale(2)
        self.play(Write(tex))
        self.wait()
        
        self.play(Flash(tex[1],flash_radius=0.6),run_time=2)
        self.wait()

The Error says that 'c^' is not a recognized color. When I delete c^ the next error is the same but with "2". Thanks for your time and your answer


Solution

  • You are using Text() to create your text, but this object does not accept several strings as arguments (only the first one is considererd the text to render, and the others are considered other arguments, in particular the fourth one is expected to be the color, hence your error).

    You probably wanted to use Tex() or MathTex(). This one works:

    class Test(Scene):
        def construct(self):
            tex= MathTex("E","=","m","c^","2").scale(2)
            self.play(Write(tex))
            self.wait()
            
            self.play(Flash(tex[1], flash_radius=0.6),run_time=2)
            self.wait()
    

    Result