from manim import *
class CounterManyDemo(Scene):
    def construct(self):
        title = Text("多个三角形同时逆时针变换为菱形", font="STLiti", font_size=28).to_edge(UP)
        self.play(FadeIn(title), run_time=0.6)
        left = [UP * 1.7 + LEFT * 2, LEFT * 2, DOWN * 1.7 + LEFT * 2]
        right = [UP * 1.7 + RIGHT * 2, RIGHT * 2, DOWN * 1.7 + RIGHT * 2]
        triangles = VGroup(*[Triangle(color=BLUE, stroke_width=7).scale(0.65).move_to(p) for p in left])
        rhombuses = VGroup(*[RegularPolygon(n=4, color=GREEN, stroke_width=7).scale(0.7).move_to(p) for p in right])
        self.play(*[FadeIn(t) for t in triangles], run_time=0.8)
        self.play(*[CounterclockwiseTransform(t, r) for t, r in zip(triangles, rhombuses)], run_time=2.4)
        note = Text("四边形的 RegularPolygon(n=4) 即菱形摆放", font="STLiti", font_size=21, color=YELLOW).to_edge(DOWN)
        self.play(FadeIn(note), run_time=0.4)
        self.wait(1.8)
