from manim import *
class BackgroundColorDemo(Scene):
    """background_color：画布底色怎么改，以及它对整帧的影响"""
    def construct(self):
        title = Text("background_color 控制画布底色", font_size=34).to_edge(UP, buff=0.5)
        self.play(Write(title))
        cards_spec = [("#0b1e3a", "深蓝", False), ("#1b1b2f", "暗紫", False),
                      ("#123a2b", "墨绿", False), ("#f2f2f2", "浅灰", True)]
        cards = VGroup()
        for hexs, name, light in cards_spec:
            box = RoundedRectangle(width=2.2, height=1.3, corner_radius=0.15,
                                   fill_color=hexs, fill_opacity=1, stroke_color=GREY)
            label = Text(name, font_size=24, color=BLACK if light else WHITE)
            label.move_to(box.get_center())
            cards.add(VGroup(box, label))
        cards.arrange(RIGHT, buff=0.45).shift(DOWN * 0.3)
        self.play(LaggedStart(*[FadeIn(c, shift=UP * 0.3) for c in cards], lag_ratio=0.2))
        self.wait(0.3)
        for hexs, _, light in cards_spec[:3]:
            self.camera.background_color = hexs
            self.wait(0.75)
        self.camera.background_color = BLACK
        self.wait(0.3)
        note = Text("底色一换，白色描边元素可能直接看不见", font_size=22, color=YELLOW)
        note.next_to(cards, DOWN, buff=0.5)
        self.play(FadeIn(note, shift=UP * 0.15))
        self.wait(1.2)
        self.wait(0.40)