from manim import *
import numpy as np
import sympy as sp
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 FormulaBasic(Scene):
    def construct(self):
        self.add(head("公式推导：平方和变完全平方", "TransformMatchingTex"))
        a = MathTex("x^2", "+2x", "+1").scale(1.3)
        b = MathTex("(x+1)", "^2").scale(1.3)
        self.add(a)
        self.wait(0.6)
        self.play(TransformMatchingTex(a, b), run_time=2.4)
        self.wait(1.2)
        self.play(b.animate.set_color(YELLOW), run_time=1.0)
        self.play(FadeIn(foot("相同子串自动配对，其余部分做形变")), run_time=0.4)
        self.wait(1.2)
