diff --git a/AI/Manim/L4Tute4.py b/AI/Manim/L4_Tute4.py similarity index 100% rename from AI/Manim/L4Tute4.py rename to AI/Manim/L4_Tute4.py diff --git a/AI/Manim/L5_GraphingMovement.py b/AI/Manim/L5_GraphingMovement.py new file mode 100644 index 00000000..45c30d37 --- /dev/null +++ b/AI/Manim/L5_GraphingMovement.py @@ -0,0 +1,48 @@ +import manim +from manim import * +from manim import ValueTracker # 需要显式导入ValueTracker + + +class GraphingMovement(Scene): + def construct(self): + #创建坐标系 + axes = Axes(x_range = [0,5,1], y_range = [0,3,1],axis_config={"include_tips":True,"numbers_to_exclude":[0]}).add_coordinates() + #位置在右上角 + axes.to_edge (UR) + #设置xy轴的显示tips,并拿到该对象 + axis_labels = axes.get_axis_labels(x_label = "x", y_label = "f(x)") + #在坐标系画图,并得到图像对象 + graph = axes.get_graph(lambda x : x**0.5, x_range = [0,4], color = YELLOW) + #将坐标系,坐标tips,图像组队 + graphing_stuff = VGroup(axes, graph, axis_labels) + #动画画出坐标系和labels + self.play(DrawBorderThenFill(axes), Write(axis_labels)) + #动画创建图像 + self.play(Create(graph)) + #将组整体移动四个单位 + self.play(graphing_stuff.animate.shift(DOWN*4), run_time=3) + #将坐标系单独向左移动 + self.play(axes.animate.shift(LEFT*3), run_time = 3) + + +# 当直接运行本脚本时执行以下代码 +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 = GraphingMovement() + # 执行渲染流程(包含文件生成和预览) + scene.render() \ No newline at end of file