-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_example.py
More file actions
53 lines (46 loc) · 1.56 KB
/
Copy pathscript_example.py
File metadata and controls
53 lines (46 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from manim import *
import math
class MathScene(Scene):
def construct(self):
# ======================
# 播放音频 1
# ======================
self.add_sound("audio/audio_001.wav")
# 画三角形
A = np.array([-2, 1, 0])
B = np.array([-3, -1, 0])
C = np.array([-1, -1, 0])
triangle = Polygon(A, B, C, color=BLUE)
self.play(Create(triangle), run_time=2)
# 标注 ABC
label_A = Text("A", font_size=24).next_to(A, UP)
label_B = Text("B", font_size=24).next_to(B, DL)
label_C = Text("C", font_size=24).next_to(C, DR)
self.play(Write(label_A), Write(label_B), Write(label_C))
self.wait(1)
# ======================
# 播放音频 2
# ======================
self.add_sound("audio/audio_002.wav")
# 画角度
angle_A = Sector(
radius=0.8,
angle=math.radians(70),
start_angle=math.radians(125),
color=YELLOW
)
self.play(Create(angle_A), run_time=1)
angle_label = Text("70°", font_size=20).move_to(angle_A.get_center() + UP*0.2)
self.play(Write(angle_label))
self.wait(1)
# ======================
# 播放音频 3
# ======================
self.add_sound("audio/audio_003.wav")
conclusion = Text(
"等腰三角形顶角70°,底角各55°",
font_size=28,
color=GREEN
).to_edge(DOWN)
self.play(FadeIn(conclusion))
self.wait(2)