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 ImplicitCircle(Scene):
    def construct(self):
        self.add(head("隐函数可视化：单位圆", "ImplicitFunction"))
        axes = Axes(x_range=[-3, 3, 1], y_range=[-3, 3, 1], x_length=7, y_length=5.4,
                    axis_config={"color": GREY_B}).add_coordinates()
        circle = ImplicitFunction(lambda x, y: x**2 + y**2 - 1,
                                  x_range=[-2.5, 2.5], y_range=[-2.5, 2.5], color=RED)
        circle.set_stroke(RED, width=6)
        label = MathTex("x^2+y^2=1", color=YELLOW).scale(0.85).to_corner(UR)
        self.add(axes, label)
        self.play(Create(circle), run_time=3)
        self.play(FadeIn(foot("求解 f(x,y)=0 的等值线，无需显式 y=f(x)")), run_time=0.4)
        self.wait(2.2)
