from manim import *
class Studying(Scene):
def construct(self):
circle = Circle(radius=0.81,color=BLUE_B)
self.play(Create(circle))
# 点的透明度为0,即看不到点
dot = Dot(point=[0.8,0,0],color=BLUE_B,fill_opacity=0)
self.play(FadeIn(dot))
# 五角星的五个点
points = VGroup()
R = 0.8
for k in range(5):
angle = k * (2 * PI * 2 / 5) # 每个点间隔 144°(=2/5圈)
x = R * np.cos(angle)
y = R * np.sin(angle)
dot_k = dot.copy().move_to([x, y, 0])
points.add(dot_k)
# 第一个创建的点渐隐
self.play(FadeOut(dot))
# 五个点渐现
for point in points:
self.play(FadeIn(point),run_time=0.1)
self.wait(0.5)
# 五个点连成五角星
hexagon = always_redraw(lambda:
Polygon(
*[point.get_center() for point in points],
stroke_width=2,
color=BLUE_B)
)
self.play(Create(hexagon),run_time=2)
self.wait(1)
# 旋转五芒星
self.play(
Rotating(VGroup(points,hexagon),
about_point=ORIGIN,
angle=4*TAU,
run_time=4,
rate_func=linear)
)