from manim import *
import numpy as np
def head(cn, en):
    t = Text(cn, font="STLiti", font_size=28).to_edge(UP)
    s = Text(en, font="Consolas", font_size=21, color=YELLOW).next_to(t, DOWN, buff=0.10)
    return VGroup(t, s)
def foot(cn):
    return Text(cn, font="STLiti", font_size=20, color=YELLOW).to_edge(DOWN)
class ShapeDemo(Scene):
    def construct(self):
        self.add(head("基础图形：任意多边形", "Polygon"))
        shape = Polygon([-3, -2, 0], [2, -2, 0], [3, 1, 0], [0, 2.5, 0], [-2, 1.5, 0], color=BLUE).set_stroke(width=7)
        self.play(Create(shape), run_time=2.2)
        self.play(shape.animate.set_stroke(YELLOW, width=7), run_time=1.2)
        self.play(FadeIn(foot("Polygon 按传入顺序依次连接所有顶点")), run_time=0.4)
        self.wait(2.2)
