main
黄海 5 months ago
parent 546ca0b4b1
commit 0971173b0b

@ -0,0 +1,51 @@
# 导入Manim核心库
from manim import *
# 导入Manim配置模块
import manim
class FittingObjects(Scene):
def construct(self):
# 坐标系放在左侧边缘
axes = Axes(x_range=[-3, 3, 1], y_range=[-3, 3, 1], x_length=6, y_length=6)
# 坐标系距离左侧有0.5的缓冲距离
axes.to_edge(LEFT, buff=0.5)
# 圆,线宽颜色,填充颜色和透明度
circle = Circle(stroke_width=6, stroke_color=YELLOW, fill_color=RED, fill_opacity=0.8)
# 圆的宽度是2位置在右下角无缓冲距离
circle.set_width(2).to_edge(DR, buff=0)
# 创建三角形高度2位置右下3.3处
triangle = Triangle(stroke_color=ORANGE, stroke_width=10, fill_color=GREY).set_height(2).shift(
DOWN * 3 + RIGHT * 3)
# 创建动画 画坐标系
self.play(Write(axes))
# 创建动画 画线然后填充圆
self.play(DrawBorderThenFill(circle))
# 形态动画 圆变化宽度
self.play(circle.animate.set_width(1))
# 转变动画 将圆向三角转变
self.play(Transform(circle, triangle), 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 = FittingObjects()
# 执行渲染流程(包含文件生成和预览)
scene.render()

@ -0,0 +1,5 @@
# This file is used internally by FFMPEG.
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L2_FittingObjects/480p15/partial_movie_files/FittingObjects/1185818338_3554391187_223132457.mp4'
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L2_FittingObjects/480p15/partial_movie_files/FittingObjects/624642324_3482381462_778707685.mp4'
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L2_FittingObjects/480p15/partial_movie_files/FittingObjects/624642324_3937821041_3069264156.mp4'
file 'file:D:/dsWork/QingLong/AI/Manim/custom_output/videos/L2_FittingObjects/480p15/partial_movie_files/FittingObjects/624642324_228721426_3069264156.mp4'
Loading…
Cancel
Save