diff --git a/AI/Manim/L3_Updaters.py b/AI/Manim/L3_Updaters.py new file mode 100644 index 00000000..b5f10880 --- /dev/null +++ b/AI/Manim/L3_Updaters.py @@ -0,0 +1,54 @@ +# 导入Manim核心库 +from manim import * +# 导入Manim配置模块 +import manim + + +class Updaters(Scene): + def construct(self): + # 创建圆角矩型,线宽8,线色白,填充色蓝,宽4.5高2,位置在上3左4 + rectangle = RoundedRectangle(stroke_width=8, stroke_color=WHITE, fill_color=BLUE_B, width=4.5, height=2).shift( + UP * 3 + LEFT * 4) + # 创建数学公式,设置渐变色,设置高度1.5 + mathtext = MathTex("\\frac{3}{4} = 0.75" + ).set_color_by_gradient(GREEN, PINK).set_height(1.5) + # 数学公式位置放在圆角矩型中间 + mathtext.move_to(rectangle.get_center()) + # 给公式添加一个更新器,公式的位置保持在圆角矩型中间 + mathtext.add_updater(lambda x: x.move_to(rectangle.get_center())) + # 开始动画播放 + # 动画,矩形出现方式 + self.play(FadeIn(rectangle)) + # 动画 公式出现 + self.play(Write(mathtext)) + # 动画,矩形移动向右1.5向下5,矩形移动时,公式跟随移动 + self.play(rectangle.animate.shift(RIGHT * 1.5 + DOWN * 5), run_time=6) + # 等待上面动画完成 + self.wait() + # 删除公式的更新器 + mathtext.clear_updaters() + # 动画,矩形向左2向上1,公式不跟随矩形移动 + self.play(rectangle.animate.shift(LEFT * 2 + UP * 1), run_time=6) + + +# 当直接运行本脚本时执行以下代码 +if __name__ == '__main__': + """ + 配置渲染参数并执行场景渲染 + 等效命令行命令: + manim -pql -o custom_output 当前文件.py BoxAnimation + """ + # 配置字典说明: + config = { + "quality": "low_quality", # 渲染质量等级(low_quality对应480p) + "preview": True, # 渲染完成后自动打开播放器 + "input_file": __file__, # 指定输入文件为当前文件 + "media_dir": "./custom_output" # 自定义输出目录(默认在media/) + } + + # 使用临时配置渲染场景(配置只在with块内有效) + with manim.tempconfig(config): + # 实例化场景类 + scene = Updaters() + # 执行渲染流程(包含文件生成和预览) + scene.render() \ No newline at end of file diff --git a/AI/Manim/custom_output/Tex/ec6ef56802578414.svg b/AI/Manim/custom_output/Tex/ec6ef56802578414.svg new file mode 100644 index 00000000..6b9775ea --- /dev/null +++ b/AI/Manim/custom_output/Tex/ec6ef56802578414.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AI/Manim/custom_output/Tex/ec6ef56802578414.tex b/AI/Manim/custom_output/Tex/ec6ef56802578414.tex new file mode 100644 index 00000000..188fff99 --- /dev/null +++ b/AI/Manim/custom_output/Tex/ec6ef56802578414.tex @@ -0,0 +1,9 @@ +\documentclass[preview]{standalone} +\usepackage[english]{babel} +\usepackage{amsmath} +\usepackage{amssymb} +\begin{document} +\begin{align*} +\frac{3}{4} = 0.75 +\end{align*} +\end{document} \ No newline at end of file diff --git a/AI/Manim/custom_output/videos/L3_Updaters/480p15/Updaters.mp4 b/AI/Manim/custom_output/videos/L3_Updaters/480p15/Updaters.mp4 new file mode 100644 index 00000000..85632af9 Binary files /dev/null and b/AI/Manim/custom_output/videos/L3_Updaters/480p15/Updaters.mp4 differ diff --git a/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/1185818338_2494747865_223132457.mp4 b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/1185818338_2494747865_223132457.mp4 new file mode 100644 index 00000000..d394e37b Binary files /dev/null and b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/1185818338_2494747865_223132457.mp4 differ diff --git a/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_1204481449_3735812780.mp4 b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_1204481449_3735812780.mp4 new file mode 100644 index 00000000..dc72a555 Binary files /dev/null and b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_1204481449_3735812780.mp4 differ diff --git a/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_2195339541_1130898081.mp4 b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_2195339541_1130898081.mp4 new file mode 100644 index 00000000..aed4c56a Binary files /dev/null and b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_2195339541_1130898081.mp4 differ diff --git a/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_2327811734_3529618872.mp4 b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_2327811734_3529618872.mp4 new file mode 100644 index 00000000..3288f829 Binary files /dev/null and b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_2327811734_3529618872.mp4 differ diff --git a/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_667144672_2981073962.mp4 b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_667144672_2981073962.mp4 new file mode 100644 index 00000000..3bc662e2 Binary files /dev/null and b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_667144672_2981073962.mp4 differ diff --git a/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/partial_movie_file_list.txt b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/partial_movie_file_list.txt new file mode 100644 index 00000000..5917f55f --- /dev/null +++ b/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/partial_movie_file_list.txt @@ -0,0 +1,6 @@ +# This file is used internally by FFMPEG. +file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/1185818338_2494747865_223132457.mp4' +file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_1204481449_3735812780.mp4' +file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_2195339541_1130898081.mp4' +file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_667144672_2981073962.mp4' +file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L3_Updaters/480p15/partial_movie_files/Updaters/624642324_2327811734_3529618872.mp4'