Search code examples
manim

How can I set the same parameters/options for multiple objects?


I started to learn how to use manin and found the following problem.

Suppose that I want the text in my video with font="Calibri" and font_size=72.

Then I have to write the following code:

Text("Text 1",font="Calibri",font_size=72)

After that, if I want to use the same style of text again, I have to write again the parameters/options of the function Text():

Text("Text 2",font="Calibri",font_size=72)

So my question is, is it possible to define a variable with the parameters/options for Text() so I won't have to copy and paste them every time?

Something like this:

options={font="Calibri",font_size=72}

Text("Text 1",options)

Text("Text 2",options)

that would simply things.


Solution

  • I figured it out! I just have to def a function:

    def font_1(text):
        new_text=Text(text,font="Calibri",font_size=72)
        return new_text
    

    Then to writte "Text 1" and "Text 2" with the same formate I just use the code

    font_1("Text 1")
    font_1("Text 2")