local configuration file D:\Manim\manim-master\custom_config.yml. You can manually modify it.也可以对于不同目录使用不同的 custom_config.yml,子文件夹下的配置文件会在运行时覆盖根目录下的总局配置文件。
classTextExample(Scene): defconstruct(self): # 想要正确运行这个场景,你需要确保你的计算机中安装了Consolas字体 # 关于Text全部用法,请见https://github.com/3b1b/manim/pull/680 # Text 可以创建文字,定义字体等 text = Text("Here is a text", font="Consolas", font_size=90) difference = Text( """ The most important difference between Text and TexText is that\n you can change the font more easily, but can't use the LaTeX grammar """, font="Arial", font_size=24, # t2c是一个由 文本-颜色 键值对组成的字典 t2c={"Text": BLUE, "TexText": BLUE, "LaTeX": ORANGE} ) # VGroup 可以将多个 VMobject 放在一起看做一个整体。 # 例子中调用了 arrange() 方法来将其中子物体依次向下排列(DOWN),且间距为 buff VGroup(text, difference).arrange(DOWN, buff=1) # Write 是显示类似书写效果的动画 self.play(Write(text)) # FadeIn 将物体淡入,第二个参数表示淡入的方向 self.play(FadeIn(difference, UP)) self.wait(3)
fonts = Text( "And you can also set the font according to different words", font="Arial", t2f={"font": "Consolas", "words": "Consolas"}, t2c={"font": BLUE, "words": GREEN} ) fonts.set_width(FRAME_WIDTH - 1) slant = Text( "And the same as slant and weight", font="Consolas", t2s={"slant": ITALIC}, t2w={"weight": BOLD}, t2c={"slant": ORANGE, "weight": RED} ) VGroup(fonts, slant).arrange(DOWN, buff=0.8) # FadeOut 将物体淡出,第二个参数表示淡出的方向 self.play(FadeOut(text), FadeOut(difference, shift=DOWN)) self.play(Write(fonts)) self.wait() self.play(Write(slant)) self.wait()