parent
5d65b74fff
commit
546ca0b4b1
@ -0,0 +1,17 @@
|
||||
from manim import *
|
||||
class NameOfAnimation(Scene):
|
||||
def construct(self):
|
||||
#创建矩形,设置边颜色和透明度,填充颜色和透明度
|
||||
box = Rectangle(stroke_color=GREEN,
|
||||
stroke_opacity=0.7, fill_color = RED_B,
|
||||
fiIl _opacity = 0.5, height=1, width=1)
|
||||
#无动画添加到场景中
|
||||
self.add(box)
|
||||
#2s内向右移动两个单位
|
||||
self.play(box.animate.shift(RIGHT*2), run time=2)
|
||||
#向上移动三个单位
|
||||
self.play(box.animate.shift(UP*3), run time=2)
|
||||
#向下自动五个单位向左移动5个单位
|
||||
self.play(box.animate.shift(DOWN*5+LEFT*5), run_time=2)
|
||||
#向上移动1.5单位向右移动一个单位
|
||||
self.play(box.animate.shift(UP*1.5+RIGHT*1), run time=2)
|
@ -0,0 +1,117 @@
|
||||
from manim import *
|
||||
|
||||
class ClearProof(Scene):
|
||||
def construct(self):
|
||||
config.frame_width = 12.8
|
||||
config.frame_height = 10.24
|
||||
colors = {
|
||||
"a": "#4D9DE0",
|
||||
"b": "#E15554",
|
||||
"c": "#3BB273",
|
||||
"bg": "#1E1E1E",
|
||||
"text": "#FFFFFF"
|
||||
}
|
||||
self.camera.background_color = colors["bg"]
|
||||
a, b = 3, 4 # 直角边长度
|
||||
c = 5 # 斜边长度
|
||||
|
||||
# ========== 第一步:初始构造 ==========
|
||||
step1 = Text("构造直角三角形", font_size=36, color=colors["text"]).to_edge(UP)
|
||||
tri = Polygon([-4, -2, 0], [2, -2, 0], [-4, 2, 0],
|
||||
color=colors["text"], stroke_width=4)
|
||||
labels = VGroup(
|
||||
MathTex("a", color=colors["a"]).next_to(tri.get_bottom(), DOWN, buff=0.3),
|
||||
MathTex("b", color=colors["b"]).next_to(tri.get_left(), LEFT, buff=0.3),
|
||||
MathTex("c", color=colors["c"]).move_to(tri.get_vertices()[2] + UR*0.5)
|
||||
)
|
||||
|
||||
self.play(Write(step1), run_time=1.5)
|
||||
self.play(Create(tri), run_time=2)
|
||||
self.play(LaggedStart(*[Write(l) for l in labels], lag_ratio=0.4))
|
||||
self.wait(2)
|
||||
|
||||
# ========== 第二步:构建正方形 ==========
|
||||
step2 = Text("构建边长的正方形", font_size=36, color=colors["text"]).to_edge(UP)
|
||||
square_a = Square(a, color=colors["a"], fill_opacity=0.3).next_to(tri, RIGHT, buff=2)
|
||||
square_b = Square(b, color=colors["b"], fill_opacity=0.3).next_to(tri, LEFT, buff=2)
|
||||
square_c = Square(c, color=colors["c"], fill_opacity=0.3).move_to(ORIGIN + DOWN*1.5)
|
||||
|
||||
self.play(
|
||||
ReplacementTransform(step1, step2),
|
||||
DrawBorderThenFill(square_a),
|
||||
DrawBorderThenFill(square_b),
|
||||
run_time=2
|
||||
)
|
||||
self.wait(1.5)
|
||||
|
||||
# ========== 第三步:分割图形 ==========
|
||||
step3 = Text("分割正方形为可重组部件", font_size=36, color=colors["text"]).to_edge(UP)
|
||||
# 分割a²正方形
|
||||
a_pieces = VGroup(
|
||||
tri.copy().set_fill(colors["a"], 0.3),
|
||||
tri.copy().rotate(PI/2).set_fill(colors["a"], 0.3).shift(RIGHT*a)
|
||||
)
|
||||
# 分割b²正方形
|
||||
b_pieces = VGroup(
|
||||
tri.copy().rotate(-PI/2).set_fill(colors["b"], 0.3),
|
||||
tri.copy().rotate(PI).set_fill(colors["b"], 0.3).shift(LEFT*b)
|
||||
)
|
||||
|
||||
self.play(
|
||||
ReplacementTransform(step2, step3),
|
||||
square_a.animate.set_fill(opacity=0),
|
||||
square_b.animate.set_fill(opacity=0),
|
||||
LaggedStart(
|
||||
Transform(square_a, a_pieces),
|
||||
Transform(square_b, b_pieces),
|
||||
lag_ratio=0.5
|
||||
),
|
||||
run_time=3
|
||||
)
|
||||
self.wait(2)
|
||||
|
||||
# ========== 第四步:重组图形 ==========
|
||||
step4 = Text("重组部件构成大正方形", font_size=36, color=colors["text"]).to_edge(UP)
|
||||
# 计算重组后的位置
|
||||
final_positions = [
|
||||
[-c/2, -c/2 -1.5, 0], [c/2, -c/2 -1.5, 0],
|
||||
[c/2, c/2 -1.5, 0], [-c/2, c/2 -1.5, 0]
|
||||
]
|
||||
# 创建重组动画
|
||||
animations = []
|
||||
for i, piece in enumerate(a_pieces):
|
||||
animations.append(piece.animate.move_to(final_positions[i]))
|
||||
for i, piece in enumerate(b_pieces):
|
||||
animations.append(piece.animate.move_to(final_positions[i+2]))
|
||||
|
||||
self.play(
|
||||
ReplacementTransform(step3, step4),
|
||||
LaggedStart(*animations, lag_ratio=0.3),
|
||||
FadeIn(square_c, shift=UP),
|
||||
run_time=4
|
||||
)
|
||||
self.wait(2)
|
||||
|
||||
# ========== 第五步:面积等式 ==========
|
||||
step5 = Text("面积守恒证明定理", font_size=36, color=colors["text"]).to_edge(UP)
|
||||
equation = MathTex(
|
||||
"a^2", "+", "b^2", "=", "c^2",
|
||||
substrings_to_isolate=["a^2", "b^2", "c^2"]
|
||||
).scale(1.5).set_color_by_tex("a^2", colors["a"]).set_color_by_tex("b^2", colors["b"]).set_color_by_tex("c^2", colors["c"])
|
||||
|
||||
self.play(
|
||||
ReplacementTransform(step4, step5),
|
||||
FadeOut(VGroup(a_pieces, b_pieces, square_c)),
|
||||
Write(equation),
|
||||
run_time=2
|
||||
)
|
||||
self.wait(3)
|
||||
|
||||
# ========== 最终总结 ==========
|
||||
conclusion = Text("勾股定理得证!", font_size=48, color=colors["c"])
|
||||
self.play(
|
||||
FadeOut(equation),
|
||||
FadeOut(step5),
|
||||
Write(conclusion, run_time=2)
|
||||
)
|
||||
self.wait(3)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
# This file is used internally by FFMPEG.
|
||||
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/BoxAnimation/480p15/partial_movie_files/BoxAnimation/1185818338_2357871401_3733939583.mp4'
|
||||
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/BoxAnimation/480p15/partial_movie_files/BoxAnimation/624642324_3298254401_3733939583.mp4'
|
||||
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/BoxAnimation/480p15/partial_movie_files/BoxAnimation/624642324_1528713618_3733939583.mp4'
|
||||
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/BoxAnimation/480p15/partial_movie_files/BoxAnimation/624642324_1659542893_3733939583.mp4'
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
# This file is used internally by FFMPEG.
|
||||
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L1/480p15/partial_movie_files/BoxAnimation/1185818338_2357871401_3733939583.mp4'
|
||||
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L1/480p15/partial_movie_files/BoxAnimation/624642324_3298254401_3733939583.mp4'
|
||||
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L1/480p15/partial_movie_files/BoxAnimation/624642324_1528713618_3733939583.mp4'
|
||||
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L1/480p15/partial_movie_files/BoxAnimation/624642324_1659542893_3733939583.mp4'
|
Loading…
Reference in new issue