61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-.py
|
|
# 场景骨架:四象限坐标系
|
|
from manim import *
|
|
|
|
class Skeleton_20250804_083501_757(Scene):
|
|
# 定义坐标轴原点位置常量
|
|
AXES_ORIGIN = ORIGIN
|
|
|
|
def construct(self):
|
|
# 创建坐标系(x∈[-3.5π,3.5π],y∈[-1.5,1.5])
|
|
axes = Axes(
|
|
x_range=[-3.5*PI, 3.5*PI, PI/2],
|
|
y_range=[-1.5, 1.5, 0.5],
|
|
axis_config={"color": WHITE},
|
|
x_axis_config={"include_numbers": True},
|
|
y_axis_config={"include_numbers": True}
|
|
).scale(0.8).shift(self.AXES_ORIGIN)
|
|
|
|
# 添加坐标轴标签
|
|
x_label = axes.get_x_axis_label("x", direction=DOWN)
|
|
y_label = axes.get_y_axis_label("y", direction=LEFT)
|
|
|
|
# 坐标轴淡入动画(持续4秒)
|
|
self.play(
|
|
FadeIn(axes, shift=UP*0.5),
|
|
FadeIn(x_label, shift=RIGHT*0.3),
|
|
FadeIn(y_label, shift=UP*0.3),
|
|
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/videos/1080p60"
|
|
# 使用临时配置渲染场景(配置只在with块内有效)
|
|
with tempconfig({
|
|
"quality": "high_quality",
|
|
"background_color": BLACK,
|
|
"preview": True,
|
|
"pixel_height": 1080,
|
|
"pixel_width": 1920,
|
|
"frame_rate": 30
|
|
}):
|
|
# 实例化场景类
|
|
scene = Skeleton_20250804_083501_757()
|
|
# 执行渲染流程(包含文件生成和预览)
|
|
scene.render() |