from manim import *
class TorusResolution(ThreeDScene):
    """2.3 提高 resolution 让曲面更平滑。
    Cairo 渲染器下 Torus 默认 resolution=(24, 24)，
    放大到 (60, 60) 后网格更密、边缘更圆润，渲染耗时也明显增加。
    原文的 (100, 100) 在 1920x1080/60fps 下实测超过 5 分钟渲染上限，
    这里取一个肉眼可辨又能在常规机器上跑完的折中值。
    """
    def construct(self):
        self.set_camera_orientation(phi=65 * DEGREES, theta=-45 * DEGREES)
        title = Text("resolution=(60, 60)  高分辨率", font="STLiti", font_size=32).to_edge(UP)
        self.add_fixed_in_frame_mobjects(title)
        torus = Torus(major_radius=2.5, minor_radius=0.5, resolution=(60, 60),
                      checkerboard_colors=[GREEN_D, GREEN_E])
        self.play(FadeIn(title), run_time=0.6)
        self.play(FadeIn(torus), run_time=1.8)
        note = Text("网格更密、边缘更圆润；分辨率越高渲染越慢",
                    font="STLiti", font_size=22, color=YELLOW).to_edge(DOWN)
        self.add_fixed_in_frame_mobjects(note)
        self.play(FadeIn(note), run_time=0.6)
        self.wait(3.2)
