65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
|
# -*- coding: utf-8 -*-.py
|
||
|
from manim import *
|
||
|
|
||
|
# 坐标轴范围常量
|
||
|
X_MIN = -3.5 * PI
|
||
|
X_MAX = 3.5 * PI
|
||
|
Y_MIN = -1.5
|
||
|
Y_MAX = 1.5
|
||
|
|
||
|
class Skeleton_20250804_084025_514(Scene):
|
||
|
def construct(self):
|
||
|
# 创建坐标系
|
||
|
axes = Axes(
|
||
|
x_range=[X_MIN, X_MAX, PI/2],
|
||
|
y_range=[Y_MIN, Y_MAX, 0.5],
|
||
|
axis_config={"color": BLUE}
|
||
|
)
|
||
|
|
||
|
# 添加坐标轴标签
|
||
|
x_label = axes.get_x_axis_label(
|
||
|
Tex("$x$").scale(0.8),
|
||
|
edge=DOWN, direction=DOWN, buff=0.4
|
||
|
)
|
||
|
y_label = axes.get_y_axis_label(
|
||
|
Tex("$y$").scale(0.8),
|
||
|
edge=LEFT, direction=LEFT, buff=0.4
|
||
|
)
|
||
|
|
||
|
# 添加坐标轴组
|
||
|
axes_group = VGroup(axes, x_label, y_label)
|
||
|
|
||
|
# 添加淡入动画
|
||
|
self.play(FadeIn(axes_group, shift=UP*0.5), run_time=4)
|
||
|
self.wait(1)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
# 导入必要的模块
|
||
|
import sys
|
||
|
import os
|
||
|
from manim import *
|
||
|
|
||
|
# 设置 UTF-8 编码
|
||
|
os.environ['PYTHONIOENCODING'] = 'utf-8'
|
||
|
sys.stdout.reconfigure(encoding='utf-8')
|
||
|
sys.stderr.reconfigure(encoding='utf-8')
|
||
|
|
||
|
# 全局指定 ctex 模板(一次性)
|
||
|
config.tex_template = TexTemplateLibrary.ctex
|
||
|
# 设置输出格式为MP4
|
||
|
config.output_format = "mp4"
|
||
|
# 设置输出目录
|
||
|
config.media_dir = "./output/"
|
||
|
# 使用临时配置渲染场景(配置只在with块内有效)
|
||
|
with tempconfig({
|
||
|
"quality": "high_quality",
|
||
|
"background_color": BLACK,
|
||
|
"preview": True,
|
||
|
"pixel_height": 1080,
|
||
|
"pixel_width": 1920,
|
||
|
"frame_rate": 30
|
||
|
}):
|
||
|
# 实例化场景类
|
||
|
scene = Skeleton_20250804_084025_514()
|
||
|
# 执行渲染流程(包含文件生成和预览)
|
||
|
scene.render()
|