from manim import *
class LabeledDotDemo(Scene):
    """2.3 LabeledDot 在点中央放标签。
    字符串 label 会交给 MathTex 渲染（黑色），适合数字、字母、公式；
    中文必须传 Text 对象并指定中文字体 STLiti，否则会渲染成豆腐块。
    """
    def construct(self):
        title = Text("带标签的点 LabeledDot", font="STLiti", font_size=34).to_edge(UP)
        self.play(Write(title), run_time=0.8)
        dots = VGroup(
            LabeledDot(Text("中文", font="STLiti", font_size=28, color=BLACK)),
            LabeledDot(r"a^2"),
            LabeledDot("32"),
            LabeledDot(r"V_i"),
        ).arrange(RIGHT, buff=1.2)
        caps = VGroup(
            Text("中文 Text", font="STLiti", font_size=22),
            Text("公式 a^2", font="STLiti", font_size=22),
            Text("数字 32", font="STLiti", font_size=22),
            Text("下标 V_i", font="STLiti", font_size=22),
        )
        for cap, dot in zip(caps, dots):
            cap.next_to(dot, DOWN, buff=0.6)
        self.play(LaggedStart(*[FadeIn(d) for d in dots], lag_ratio=0.3),
                  run_time=2.2)
        self.play(FadeIn(caps), run_time=0.6)
        self.wait(2.4)
