Search code examples
pythonmanim

Objects' color after changing background color in manim


I'm trying to change the background of my Scene in manim video with a self.camera.background-color= WHITE, the background changed well but all texts are still white.

Is there any other methods to invert all colors in the scene or we have to define each object's color by a .set_color(BLACK) ??🤔 Thanks for responding...still newbie😅


Solution

  • You can set the default colors for all different types of objects in Manim.

    from manim import *
    
    config.background_color = "#a0a0a0"
    Tex.set_default(color=BLACK)
    MathTex.set_default(color=TEAL)
    Text.set_default(color=PURE_GREEN)
    Square.set_default(color=PURE_BLUE)
    Circle.set_default(color=PURE_RED)
    
    class test(Scene):
        def construct(self):
            sq = Square().to_corner(UR)
            circ = Circle().to_corner(UL)
            text = Text("Hello World").to_edge(LEFT)
            tex = Tex(r"Hello \LaTeX").shift(UP)
            mathtex = MathTex(r"a^2+b^2=c^2").shift(DOWN)
            self.add(sq,circ,text,tex,mathtex)
    

    test scene

    On the Manim Discord server there are some more advanced solution for defining your own color schemes...