from manim import * classClockManyDemo(Scene): defconstruct(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] circles = VGroup(*[Circle(radius=0.55, color=BLUE, stroke_width=7).move_to(p) for p in left]) squares = VGroup(*[Square(side_length=1.0, color=YELLOW, stroke_width=7).move_to(p) for p in right]) self.play(*[FadeIn(c) for c in circles], run_time=0.8) self.play(*[ClockwiseTransform(c, s) for c, s inzip(circles, squares)], run_time=2.4) note = Text("逐对指定源与目标,三个变换同时播放", font="STLiti", font_size=21, color=YELLOW).to_edge(DOWN) self.play(FadeIn(note), run_time=0.4) self.wait(1.8)
from manim import * classCounterManyDemo(Scene): defconstruct(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 inzip(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)