from manim import *
import numpy as np
def head(cn, en):
    t = Text(cn, font="STLiti", font_size=27).to_edge(UP)
    s = Text(en, font="Consolas", font_size=20, color=YELLOW).next_to(t, DOWN, buff=0.10)
    return VGroup(t, s)
def foot(cn):
    return Text(cn, font="STLiti", font_size=20, color=YELLOW).to_edge(DOWN)
class CameraFocusDemo(MovingCameraScene):
    def construct(self):
        self.add(head("相机：移动焦点", "MovingCameraScene / camera.frame"))
        a = Circle(radius=1.0, color=RED).set_fill(RED, opacity=0.4).shift(LEFT * 4)
        b = Square(side_length=1.8, color=BLUE).set_fill(BLUE, opacity=0.4).shift(RIGHT * 4)
        self.add(a, b)
        self.play(self.camera.frame.animate.move_to(a), run_time=2.2)
        self.play(self.camera.frame.animate.move_to(b), run_time=2.2)
        self.play(FadeIn(foot("只移动相机，画面里对象的坐标并没有变")), run_time=0.4)
        self.wait(1.2)
