例10 看图写程序,显示logo
class ManimCELogo(Scene):
def construct(self):
#设置背景色
self.camera.background_color = "#ece6e2"
#定义几个颜色
logo_green = "#87c2a5"
logo_blue = "#525893"
logo_red = "#e07a5f"
logo_black = "#343434"
#定义公式M,放大7,颜色黑色
ds_m = MathTex(r"\mathbb{M}", fill_color=logo_black).scale(7)
#设置公式位置左上
ds_m.shift(2.25 * LEFT + 1.5 * UP)
#定义圆,绿色,不透明度1,左侧
circle = Circle(color=logo_green, fill_opacity=1).shift(LEFT)
#定义矩形,蓝色,不透明度,位置上
square = Square(color=logo_blue, fill_opacity=1).shift(UP)
#定义三角形,红色,不透明度1,右侧位置
triangle = Triangle(color=logo_red, fill_opacity=1).shift(RIGHT)
#将前面定义的几个对象编组
logo = VGroup(triangle, square, circle, ds_m) # order matters
#组整体移动到原点
logo.move_to(ORIGIN)
#播放创建动画
self.play(Create(logo), run_time=4)
# don't remove below command for run button to work
%manim -qm -i ManimCELogo