其他分享
首页 > 其他分享> > Halogenation of alkanes

Halogenation of alkanes

作者:互联网

%%manim -v WARNING -qh s1
class s1(Scene):
    def construct(self):
        def getall():
            alls = self.mobjects
            vg = VGroup()
            for i in alls:
                vg.add(i)
            return vg
        
        class narrator(Text):
            def __init__(
                self,
                *text_parts,
                font: str = "STZhongsong",
                **kwargs
            ):
                self.font = font
                super().__init__(*text_parts,font=font,**kwargs)
                self.to_edge(DOWN)
                self.scale(0.6)
                
        class upnarrator(Text):
            def __init__(
                self,
                *text_parts,
                font: str = "STZhongsong",
                **kwargs
            ):
                self.font = font
                super().__init__(*text_parts,font=font,**kwargs)
                self.to_edge(UP)
                self.scale(0.8)
        
        def check(svg):
            n = 0
            for i in svg:
                num = Integer(number=n).scale(0.6).set_color(RED).move_to(i)
                n += 1
                self.add(num)
                self.add(svg.set_opacity(0.5))
        
        
        
        title = Text('烷烃的卤化', font='STZhongsong')
        self.play(DrawBorderThenFill(title))
        self.play(FadeOut(title))
        t0 = narrator('烷烃中的氢原子被卤原子取代的反应称为卤代反应')
        t1 = narrator('包括氟化、氯化、溴化和碘化')
        t2 = narrator('但有实际意义的卤化反应是氯化和溴化')
        t2[12:14].set_color("#32cd32")
        t2[15:].set_color("#5599ff")
        m1 = MarkupText('CH<sub>4</sub>')
        m2 = MarkupText('<gradient from="#ffffff" to="#cc3333">CH<sub>3</sub>F</gradient>')
        m3 = MarkupText('<gradient from="#ffffff" to="#32cd32">CH<sub>3</sub>Cl</gradient>')
        m4 = MarkupText('<gradient from="#ffffff" to="#5599ff">CH<sub>3</sub>Br</gradient>')
        m5 = MarkupText('<gradient from="#ffffff" to="#9955ff">CH<sub>3</sub>I</gradient>')
        self.play(DrawBorderThenFill(t0),DrawBorderThenFill(m1))
        self.play(ReplacementTransform(t0,t1))
        self.play(TransformMatchingShapes(m1,m2), t1[2:4].animate.set_color("#cc3333"))
        self.wait(0.2)
        self.play(TransformMatchingShapes(m2,m3), t1[2:4].animate.set_color(WHITE), t1[5:7].animate.set_color("#32cd32"))
        self.wait(0.2)
        self.play(TransformMatchingShapes(m3,m4), t1[5:7].animate.set_color(WHITE), t1[8:10].animate.set_color("#5599ff"))
        self.wait(0.2)
        self.play(TransformMatchingShapes(m4,m5), t1[8:10].animate.set_color(WHITE), t1[11:].animate.set_color("#9955ff"))
        self.wait(0.2)
        m3 = MarkupText('<gradient from="#ffffff" to="#32cd32">CH<sub>3</sub>Cl</gradient>')
        m4 = MarkupText('<gradient from="#ffffff" to="#5599ff">CH<sub>3</sub>Br</gradient>')
        vgx = VGroup(m3,m4).arrange(3*RIGHT)
        self.play(Transform(t1,t2), Transform(m5, vgx))
        self.wait(1)
        self.play(FadeOut(m5), FadeOut(t1))

        cl2 = SVGMobject(r'D:\manimSVG\cl2.svg').scale(0.35)
        clbond = SVGMobject(r'D:\manimSVG\clbond.svg').match_height(cl2)
        clleft = SVGMobject(r'D:\manimSVG\clleft.svg').match_height(cl2)
        clright = SVGMobject(r'D:\manimSVG\clright.svg').match_height(cl2)
        methyl = SVGMobject(r'D:\manimSVG\methyl.svg').match_height(cl2).set_color(GOLD).set_sheen(1)
        methylradical = SVGMobject(r'D:\manimSVG\methylradical.svg').match_height(cl2).set_color(GOLD).set_sheen(1)
        ccl = SVGMobject(r'D:\manimSVG\ccl.svg').match_height(cl2).set_color(GOLD).set_sheen(1)
        
        t1 = Text('甲烷的氯化', font='STZhongsong').scale(0.7)
        t1c = t1.copy()
        t2 = Text('甲烷的卤化', font='STZhongsong').scale(0.7)
        t3 = Text('高级烷烃的卤化', font='STZhongsong').scale(0.7)
        vgt = VGroup(t1,t2,t3).arrange(4*DOWN)
        self.play(DrawBorderThenFill(vgt))
        vgfadeout = VGroup(t2,t3)
        self.play(FadeOut(vgfadeout))
        self.play(Transform(t1,cl2))
        nar = upnarrator('链引发')
        self.play(DrawBorderThenFill(nar))
        vcl = VGroup(clleft,clright).arrange(3.2*RIGHT)
        l = clleft.copy().set_color(GREEN).set_sheen(1)
        r = clright.copy()
        dotvg = VGroup(l[2], r[2]).set_color(GREEN).set_sheen(1)
        self.play(Transform(t1,clbond))
        hv = Text('热或光', font='STZhongsong').scale(0.8).next_to(t1, 3*DOWN).set_sheen(1)
        hv[0].set_color(RED)
        hv[1].set_color(WHITE)
        hv[2].set_color(GOLD)
        self.play(GrowFromPoint(hv, hv.get_center()), rate_func=rate_functions.rush_from)
        self.play(t1.animate.set_color(GREEN), run_time=0.5)
        self.play(t1.animate.set_sheen(1), run_time=0.5)
        ag = AnimationGroup(Wiggle(t1[0:2], scale_value = 1.2, rotation_angle = PI/12), Wiggle(t1[2:4], scale_value = 1.2, rotation_angle = PI/12))
        self.play(AnimationGroup(ag,Transform(t1[4], dotvg), lag_ratio=0.2))
        self.play(FadeOut(hv))
        t0 = narrator('产生高能量的氯自由基,引发反应')
        t0[6:10].set_color(GREEN).set_sheen(1)
        self.play(DrawBorderThenFill(t0))
        self.add(l[2])
        self.play(FadeOut(t1[2:]), FadeOut(nar), FadeOut(t0))
        radical = VGroup(l[2], t1[0:2])
        rc = radical.copy()
        rcc = radical.copy()
        self.play(radical.animate.move_to(np.array([-4.5,0,0])))
        t2 = narrator('并不断生成氯甲烷分子')
        t2[5:].set_color(GOLD).set_sheen(1)
        t1 = narrator('一个氯自由基消失,产生另一个氯自由基,反复循环').next_to(t2, UP)
        t1[2:6].set_color(GREEN).set_sheen(1)
        t1[14:18].set_color(GREEN).set_sheen(1)
        t0 = VGroup(t1,t2)
        nar = upnarrator('链转移')
        self.play(DrawBorderThenFill(methyl), DrawBorderThenFill(nar), DrawBorderThenFill(t0))
        o2 = SVGMobject(r'D:\manimSVG\o2.svg').scale(0.2).next_to(nar, 2*DOWN)
        o2[0:2].set_color(GREEN).set_sheen(0.3)
        o2[10:14].set_color(GREEN).set_sheen(0.3)
        o2[10:14].set_color(GREEN).set_sheen(0.3)
        o2[3:9].set_color(GOLD).set_sheen(0.3)
        o2[14].set_color(GOLD).set_sheen(0.3)
        o3 = SVGMobject(r'D:\manimSVG\o3.svg').scale(0.2).next_to(o2, DOWN).set_opacity(0.5)
        o3[4:7].set_color(GREEN).set_sheen(0.3)
        o3[13:15].set_color(GREEN).set_sheen(0.3)
        o3[16].set_color(GREEN).set_sheen(0.3)
        o3[0:3].set_color(GOLD).set_sheen(0.3)
        o3[15].set_color(GOLD).set_sheen(0.3)
        o3[7:12].set_color(GOLD).set_sheen(0.3)
        self.play(DrawBorderThenFill(o2), DrawBorderThenFill(o3))
        self.play(radical.animate.move_to(methyl.get_left() + 0.1*LEFT), rate_func=rate_functions.rush_into)
        hcl = SVGMobject(r'D:\manimSVG\hcl.svg').set_color(GREEN).set_sheen(1).match_height(cl2).move_to(radical.get_left() + 0.3*LEFT)
        self.add(methylradical)
        self.remove(methyl)
        self.play(Transform(radical,hcl, run_time=0.2), methylradical.animate.move_to(np.array([4.5,0,0])), rate_func=rate_functions.rush_from)
        self.play(FadeOut(radical))
        self.play(methylradical.animate.move_to(np.array([-4.5,0,0])), o2.animate.set_opacity(0.5), o3.animate.set_opacity(1))
        cl2 = SVGMobject(r'D:\manimSVG\cl2.svg').scale(0.35).set_color(GREEN).set_sheen(1)
        rc.move_to(cl2)
        self.play(DrawBorderThenFill(cl2))
        self.play(methylradical.animate.move_to(cl2.get_left() + 0.1*LEFT), rate_func=rate_functions.rush_into)
        self.add(rc)
        self.remove(cl2)
        ccl.move_to(methylradical.get_left() + 0.3*LEFT)
        self.play(Transform(methylradical,ccl, run_time=0.2), rc.animate.move_to(np.array([4.5,0,0])), rate_func=rate_functions.rush_from)
        self.play(FadeOut(methylradical))
        self.play(rc.animate.move_to(np.array([-4.5,0,0])), o2.animate.set_opacity(1), o3.animate.set_opacity(0.5))
#         重新命名
        methyl = SVGMobject(r'D:\manimSVG\methyl.svg').match_height(cl2).set_color(GOLD).set_sheen(1)
        methylradical = SVGMobject(r'D:\manimSVG\methylradical.svg').match_height(cl2).set_color(GOLD).set_sheen(1)
        ccl = SVGMobject(r'D:\manimSVG\ccl.svg').match_height(cl2).set_color(GOLD).set_sheen(1)
        self.play(DrawBorderThenFill(methyl))
        self.play(rc.animate.move_to(methyl.get_left() + 0.1*LEFT), rate_func=rate_functions.rush_into)
        hcl = SVGMobject(r'D:\manimSVG\hcl.svg').set_color(GREEN).set_sheen(1).match_height(cl2).move_to(rc.get_left() + 0.3*LEFT)
        self.add(methylradical)
        self.remove(methyl)
        self.play(Transform(rc,hcl, run_time=0.2), methylradical.animate.move_to(np.array([4.5,0,0])), rate_func=rate_functions.rush_from)
        self.play(FadeOut(rc))
        self.play(methylradical.animate.move_to(np.array([-4.5,0,0])), o2.animate.set_opacity(0.5), o3.animate.set_opacity(1))
        cl2 = SVGMobject(r'D:\manimSVG\cl2.svg').scale(0.35).set_color(GREEN).set_sheen(1)
        rcc.move_to(cl2)
        self.play(DrawBorderThenFill(cl2))
        self.play(methylradical.animate.move_to(cl2.get_left() + 0.1*LEFT), rate_func=rate_functions.rush_into)
        self.add(rcc)
        self.remove(cl2)
        ccl.move_to(methylradical.get_left() + 0.3*LEFT)
        self.play(Transform(methylradical,ccl, run_time=0.2), rcc.animate.move_to(np.array([4.5,0,0])), rate_func=rate_functions.rush_from)
        self.play(FadeOut(methylradical), FadeOut(rcc), FadeOut(t0), FadeOut(nar), FadeOut(o2), FadeOut(o3))
        
        self.wait(2)

 

%%manim -v WARNING -qh s2
class s2(Scene):
    def construct(self):
        def getall():
            alls = self.mobjects
            vg = VGroup()
            for i in alls:
                vg.add(i)
            return vg
        
        class narrator(Text):
            def __init__(
                self,
                *text_parts,
                font: str = "STZhongsong",
                **kwargs
            ):
                self.font = font
                super().__init__(*text_parts,font=font,**kwargs)
                self.to_edge(DOWN)
                self.scale(0.6)
                
        class upnarrator(Text):
            def __init__(
                self,
                *text_parts,
                font: str = "STZhongsong",
                **kwargs
            ):
                self.font = font
                super().__init__(*text_parts,font=font,**kwargs)
                self.to_edge(UP)
                self.scale(0.8)
        
        def check(svg):
            n = 0
            for i in svg:
                num = Integer(number=n).scale(0.6).set_color(RED).move_to(i)
                n += 1
                self.add(num)
                self.add(svg.set_opacity(0.5))
        note = upnarrator('链终止')                    
        a = narrator('反应物浓度降低,自由基碰撞机会增加')
        self.play(DrawBorderThenFill(note),DrawBorderThenFill(a))
        cl = SVGMobject(r'D:\manimSVG\clleft.svg').set_color(GREEN).set_sheen(1).scale(0.25).move_to(np.array([-3.5,2,0]))
        cl2 = cl.copy().move_to(np.array([3.5,2,0]))
        cl3 = cl.copy().move_to(np.array([3.5,-2,0]))
        mr = SVGMobject(r'D:\manimSVG\methylradical.svg').match_height(cl).set_color(GOLD).set_sheen(1).move_to(np.array([-3.5,0,0]))
        mr2 = mr.copy().move_to(np.array([3.5,0,0]))
        mr3 = mr.copy().move_to(np.array([-3.5,-2,0]))
        ccl = SVGMobject(r'D:\manimSVG\ccl.svg').match_height(cl).set_color(GOLD).set_sheen(1).move_to(np.array([0,-2,0]))
        cc = SVGMobject(r'D:\manimSVG\ethyl.svg').match_height(cl).set_color(GOLD).set_sheen(1)
        clcl = SVGMobject(r'D:\manimSVG\cl2.svg').match_height(cl).set_color(GREEN).set_sheen(1).move_to(np.array([0,2,0]))
        self.play(FadeIn(cl),FadeIn(cl2),FadeIn(cl3))
        self.play(FadeIn(mr),FadeIn(mr2),FadeIn(mr3))
        
        self.play(cl.animate.move_to(np.array([-0.4,2,0])),cl2.animate.move_to(np.array([0.4,2,0])), rate_func=rate_functions.rush_into)
        self.remove(cl, cl2)
        self.add(clcl)
        self.play(Wiggle(clcl, scale_value = 1.5, rotation_angle = PI/12), rate_func=rate_functions.rush_from)

        self.play(mr.animate.move_to(np.array([-0.6,0,0])),mr2.animate.move_to(np.array([0.6,0,0])), rate_func=rate_functions.rush_into)
        self.remove(mr, mr2)
        self.add(cc)
        self.play(Wiggle(cc, scale_value = 1.5, rotation_angle = PI/12), rate_func=rate_functions.rush_from)

        self.play(cl3.animate.move_to(np.array([0.5,-2,0])),mr3.animate.move_to(np.array([-0.5,-2,0])), rate_func=rate_functions.rush_into)
        self.remove(cl3, mr3)
        self.add(ccl)
        self.play(Wiggle(ccl, scale_value = 1.5, rotation_angle = PI/12), rate_func=rate_functions.rush_from)

        a2 = narrator('自由基消失,反应结束')
        self.play(Transform(a,a2))
        self.wait(1)
        
        alll = VGroup(ccl,cc,clcl,a,note)
        t1 = Text('甲烷的氯化', font='STZhongsong').scale(0.7)
        t2 = Text('甲烷的卤化', font='STZhongsong').scale(0.7)
        t3 = Text('高级烷烃的卤化', font='STZhongsong').scale(0.7)
        vgt = VGroup(t1,t2,t3).arrange(4*DOWN)
        vgfadeout = VGroup(t2,t3)
        self.play(Transform(alll, t1))
        self.play(FadeIn(vgfadeout))
        self.wait(1)

 

%%manim -v WARNING -qh s3
class s3(Scene):
    def construct(self):
        
        def getall():
            alls = self.mobjects
            vg = VGroup()
            for i in alls:
                vg.add(i)
            return vg
        
        class narrator(Text):
            def __init__(
                self,
                *text_parts,
                font: str = "STZhongsong",
                **kwargs
            ):
                self.font = font
                super().__init__(*text_parts,font=font,**kwargs)
                self.to_edge(DOWN)
                self.scale(0.6)
                
        class upnarrator(Text):
            def __init__(
                self,
                *text_parts,
                font: str = "STZhongsong",
                **kwargs
            ):
                self.font = font
                super().__init__(*text_parts,font=font,**kwargs)
                self.to_edge(UP)
                self.scale(0.8)
        
        def check(svg):
            n = 0
            for i in svg:
                num = Integer(number=n).scale(0.6).set_color(RED).move_to(i)
                n += 1
                self.add(num)
                self.add(svg.set_opacity(0.5))
        
        t1 = Text('甲烷的氯化', font='STZhongsong').scale(0.7)
        t2 = Text('甲烷的卤化', font='STZhongsong').scale(0.7)
        t2c = t2.copy()
        t3 = Text('高级烷烃的卤化', font='STZhongsong').scale(0.7)
        vgt = VGroup(t1,t2,t3).arrange(4*DOWN)
        self.add(vgt)
        self.wait(1)
        vgfadeout = VGroup(t1,t3)
        self.play(FadeOut(vgfadeout))
        e = SVGMobject(r'D:\manimSVG\equation.svg').scale(0.2)
        ee = e.copy()
        vg0 = VGroup(e[0:5], e[11])
        x = VGroup(e[0], e[11])
        cr = VGroup(e[5:8], e[12])
        sign1 = MathTex(r'\Delta H^{\Theta }\left ( kJ\cdot mol^{-1}  \right )').scale(0.8)
        sign2 = MathTex(r'E_{a}\left ( kJ\cdot mol^{-1}  \right )').match_height(sign1).shift(1.5*DOWN)
        self.play(Transform(t2,vg0))
        self.play(GrowFromCenter(e[13:]))
        self.play(ClockwiseTransform(x,e[9:11]), rate_func=rate_functions.smooth)
        self.play(CounterclockwiseTransform(e[2:5],cr), rate_func=rate_functions.smooth)
        a0 = narrator('在链转移过程中,此步的活化能最高,为决速步')
        a1 = narrator('通过比较活化能大小可以得知反应进行的难易')
        self.play(FadeIn(e[8]), DrawBorderThenFill(a0))
        self.play(Transform(a0, a1))
        self.wait(1)
        self.play(FadeOut(a0))
        self.clear()
        self.add(ee)
        self.play(ee.animate.shift(1.5*UP))
        self.play(ee.animate.scale(1.6))
        vgsign = VGroup(sign1, sign2).arrange(RIGHT, buff=2).next_to(ee, 2*DOWN)
        self.play(DrawBorderThenFill(sign1), DrawBorderThenFill(sign2))
        f1 = Text('F', font='Times New Roman').match_height(ee[0]).move_to(ee[0]).set_sheen(0.3).set_color("#CC3333")
        f2 = f1.copy().move_to(ee[10])
        self.play(Transform(ee[0], f1), Transform(ee[10], f2))
        n1 = Text('-128.9').scale(0.8).set_sheen(0.3).set_color("#CC3333").next_to(sign1, 2*DOWN)
        n2 = Text('+4.2').scale(0.8).set_sheen(0.3).set_color("#CC3333").next_to(sign2, 2*DOWN)
        self.play(GrowFromCenter(n1), GrowFromCenter(n2))
        a0 = narrator('氟与甲烷一旦发生反应,会大量放热')
        a1 = narrator('这会破坏生成的氟甲烷,而得到碳和氟化氢')
        a2 = narrator('因此,直接氟化的反应很难实现')
        self.play(DrawBorderThenFill(a0))
        self.play(n1.animate.scale(2))
        cf = SVGMobject(r'D:\manimSVG\cf.svg').scale(0.28).shift(2*DOWN)
        self.play(Transform(a0, a1))
        self.play(FadeIn(cf))
        self.play(cf.animate.set_color("#FF0000"), run_time=2)
        self.play(cf.animate.set_sheen(0.3), run_time=0.5)
        c = Text('C', font='Times New Roman').match_height(cf).scale(0.9).move_to(cf).shift(1.5*LEFT).set_sheen(0.3).set_color("#FF0000")
        hf = Text('HF', font='Times New Roman').match_height(cf).scale(0.9).move_to(cf).shift(1.5*RIGHT).set_sheen(0.3).set_color("#FF0000")
        vgf = VGroup(c, hf)
        self.play(Transform(cf, vgf))
        self.play(Transform(a0, a2))
        self.wait(1)
        self.play(FadeOut(n1), FadeOut(n2), FadeOut(a0), FadeOut(cf))
        
        i1 = Text('I', font='Times New Roman').match_height(ee[0]).move_to(ee[0]).set_sheen(0.3).set_color("#9955ff")
        i2 = i1.copy().move_to(ee[10])
        self.play(Transform(ee[0], i1), Transform(ee[10], i2))
        n1 = Text('+141').scale(0.8).set_sheen(0.3).set_color("#9955ff").next_to(sign1, 2*DOWN)
        n2 = Text('>+141').scale(0.8).set_sheen(0.3).set_color("#9955ff").next_to(sign2, 2*DOWN)
        self.play(GrowFromCenter(n1), GrowFromCenter(n2))
        a0 = narrator('碘不易与甲烷发生取代反应,因为活化能太高')
        self.play(DrawBorderThenFill(a0))
        self.play(n2.animate.scale(2))
        self.play(FadeOut(n1), FadeOut(n2), FadeOut(a0))
        self.wait(1)
        
        i1 = Text('Cl', font='Times New Roman').match_height(ee[0]).move_to(ee[0]).set_sheen(0.3).set_color("#32cd32").shift(0.05*LEFT)
        i2 = i1.copy().move_to(ee[10]).shift(0.05*RIGHT)
        self.play(Transform(ee[0], i1), Transform(ee[10], i2))
        n2 = Text('+16.7').scale(0.8).set_sheen(0.3).set_color("#32cd32").next_to(sign2, 2*DOWN)
        n1 = Text('+7.5').scale(0.8).set_sheen(0.3).set_color("#32cd32").next_to(sign1, 2*DOWN).set_y(n2.get_y())
        ic = i1.copy().next_to(n1, 3*LEFT).set_y(n2.get_y())
        self.play(GrowFromCenter(n1), GrowFromCenter(n2))
        self.play(Write(ic))
        self.wait(1.5)
        
        b1 = Text('Br', font='Times New Roman').match_height(ee[0]).move_to(ee[0]).set_sheen(0.3).set_color("#5599ff").shift(0.05*LEFT)
        b2 = b1.copy().move_to(ee[10])
        self.play(Transform(ee[0], b1), Transform(ee[10], b2))
        nn2 = Text('+75.3').scale(0.8).set_sheen(0.3).set_color("#5599ff").next_to(n2, 2*DOWN)
        nn1 = Text('+73.2').scale(0.8).set_sheen(0.3).set_color("#5599ff").next_to(n1, 2*DOWN).set_y(nn2.get_y())
        bc = b1.copy().next_to(nn1, 3*LEFT).set_y(nn2.get_y()).set_x(ic.get_x()).shift(0.05*RIGHT)
        self.play(GrowFromCenter(nn1), GrowFromCenter(nn2))
        self.play(Write(bc))
        
        x1 = Text('X', font='Times New Roman').match_height(ee[0]).move_to(ee[0]).shift(0.1*RIGHT)
        x2 = x1.copy().move_to(ee[10]).shift(0.05*LEFT)
        self.play(Transform(ee[0], x1), Transform(ee[10], x2))
        
        na0 = narrator('卤化反应主要为氯化、溴化,因为这两者的活化能都不高')
        self.play(DrawBorderThenFill(na0))
        self.play(Wiggle(n2, scale_value = 1.5, rotation_angle = PI/12), Wiggle(nn2, scale_value = 1.5, rotation_angle = PI/12))
        self.wait(1)
        
        vgall = VGroup(ee, sign1, sign2, n1, n2, nn1, nn2, ic, bc, na0)
        self.play(Transform(vgall, t2c))
        self.play(FadeIn(vgfadeout))
        self.wait(1)

 

%%manim -v WARNING -qh s4
class s4(Scene):
    def construct(self):
        def check(svg):
            n = 0
            for i in svg:
                num = Integer(number=n).scale(0.6).set_color(RED).move_to(i)
                n += 1
                self.add(num)
                self.add(svg.set_opacity(0.5))
                
        class narrator(Text):
            def __init__(
                self,
                *text_parts,
                font: str = "STZhongsong",
                **kwargs
            ):
                self.font = font
                super().__init__(*text_parts,font=font,**kwargs)
                self.to_edge(DOWN)
                self.scale(0.6)
        
#         e1 = SVGMobject(r'D:\manimSVG\sigma1.svg').scale(2)
#         e1[3].set_color(BLUE)
#         e1[0].set_color(BLUE)

#         e2 = SVGMobject(r'D:\manimSVG\sigma2.svg').scale(2)
#         e2[0].set_color(BLUE)
#         e2[2].set_color(BLUE)
#         e2[4].set_color(BLUE)
#         e2[7].set_color(BLUE)
#         e2[10].set_color(BLUE)

#         zhong = SVGMobject(r'D:\manimSVG\zhong.svg').scale(2)
#         zhong[3].set_color(BLUE)
#         zhong[0].set_color(BLUE)
        
#         shu = SVGMobject(r'D:\manimSVG\shu.svg').scale(2)
#         shu[3].set_color(BLUE)
#         shu[0].set_color(BLUE)

        t1 = Text('甲烷的氯化', font='STZhongsong').scale(0.7)
        t2 = Text('甲烷的卤化', font='STZhongsong').scale(0.7)
        t3 = Text('高级烷烃的卤化', font='STZhongsong').scale(0.7)
        vgt = VGroup(t1,t2,t3).arrange(4*DOWN)
        t3c = t3.copy()
        self.add(vgt)
        self.wait(1)
        vgfadeout = VGroup(t1,t2)
        self.play(FadeOut(vgfadeout))
        begin = SVGMobject(r'D:\manimSVG\begin.svg')
        self.play(Transform(t3,begin))
        
        cl = Text('Cl', font='Times New Roman').move_to(begin[11]).match_height(begin[11]).set_color("#32cd32").set_sheen(0.3)
        br = Text('Br', font='Times New Roman').move_to(begin[11]).match_height(begin[11]).set_color("#5599ff").set_sheen(0.3)
        f = Text('F', font='Times New Roman').move_to(begin[11]).match_height(begin[11]).set_color("#cc3333").set_sheen(0.3)
        i = Text('I', font='Times New Roman').move_to(begin[11]).match_height(begin[11]).set_color("#9955ff").set_sheen(0.3)
        n1 = narrator('在紫外光或热作用下,氯、溴能与高级烷烃发生反应')
        n1[10].set_color("#32cd32").set_sheen(0.3)
        n1[12].set_color("#5599ff").set_sheen(0.3)
        n2 = narrator('氟可在惰性气体稀释下进行烷烃的氟化,而碘不能')
        n2[0].set_color("#cc3333").set_sheen(0.3)
        n2[19].set_color("#9955ff").set_sheen(0.3)
        self.play(Transform(t3[11], cl), DrawBorderThenFill(n1))
        self.play(Transform(t3[11], br))
        self.wait()
        self.play(Transform(t3[11], f), Transform(n1, n2))
        self.wait()
        self.play(Transform(t3[11], i))
        self.wait()
        self.play(FadeOut(t3), FadeOut(n1))
        
        
        cle1 = SVGMobject(r'D:\manimSVG\cle1.svg').scale(0.7).shift(2.5*UP)
        cle1[12:15].set_color(GREEN).set_sheen(0.3)
        cle1[24:26].set_color(GREEN).set_sheen(0.3)
        cle1[43:45].set_color(GREEN).set_sheen(0.3)
        cle1[38:40].set_color(GREEN).set_sheen(0.3)

        mo1 = cle1[1:10].copy()
        mo2 = cle1[12:15].copy()
        mo3 = cle1[15:26].copy()
        mo4 = VGroup(cle1[27:35].copy(), cle1[43:46].copy())
        vmo1 = VGroup(mo1, mo2)
        self.play(FadeIn(vmo1))
        self.play(TransformMatchingShapes(vmo1, mo3))
        self.play(FadeIn(vmo1))
        self.play(TransformMatchingShapes(vmo1, mo4))
        self.play(FadeIn(cle1))
        num1 = Text('45%').next_to(cle1[15:26], DOWN).scale(0.6).set_color(GREEN).set_sheen(0.3)
        num2 = Text('55%').next_to(cle1[27:35], DOWN).scale(0.6).set_y(num1.get_y()).set_color(GREEN).set_sheen(0.3)
        self.play(GrowFromCenter(num1), GrowFromCenter(num2))
        
        self.remove(mo3, mo4)
        cle2 = SVGMobject(r'D:\manimSVG\cle2.svg').scale(0.7).shift(0.7*DOWN)
        cle2[2:5].set_color(GREEN).set_sheen(0.3)
        cle2[13:15].set_color(GREEN).set_sheen(0.3)
        cle2[23:25].set_color(GREEN).set_sheen(0.3)
        cle2[28:30].set_color(GREEN).set_sheen(0.3)

        mo1 = cle2[39:51].copy()
        mo2 = cle2[2:5].copy()
        mo3 = VGroup(cle2[5:15].copy(), cle2[51:55].copy())
        mo4 = cle2[16:25].copy()
        vmo1 = VGroup(mo1, mo2)
        self.play(FadeIn(vmo1))
        self.play(TransformMatchingShapes(vmo1, mo3))
        self.play(FadeIn(vmo1))
        self.play(TransformMatchingShapes(vmo1, mo4))
        self.play(FadeIn(cle2))
        num3 = Text('64%').next_to(cle2[5:15], DOWN).scale(0.6).set_x(num1.get_x()).set_color(GREEN).set_sheen(0.3)
        num4 = Text('36%').scale(0.6).set_x(num2.get_x()).set_y(num3.get_y()).set_color(GREEN).set_sheen(0.3)
        self.play(GrowFromCenter(num3), GrowFromCenter(num4))
        self.remove(mo3, mo4)
        self.wait()
        
        h1 = Text('1°H').next_to(cle1[1:10], DOWN).scale(0.6).set_color(TEAL).set_sheen(0.3)
        h2 = Text('2°H').next_to(cle1[12:15], DOWN).scale(0.6).set_color(RED).set_sheen(0.3).set_y(h1.get_y()).shift(0.2*LEFT)
        h3 = Text('1°H').next_to(cle2[38:41], DOWN).scale(0.6).set_color(TEAL).set_sheen(0.3).set_x(h1.get_x())
        h4 = Text('3°H').set_x(h2.get_x()).set_y(h3.get_y()).scale(0.6).set_color(PURPLE).set_sheen(0.3)
        na1 = narrator('丙烷中有六个伯氢、两个仲氢')
        na1[6:8].set_color(TEAL).set_sheen(0.3)
        na1[11:13].set_color(RED).set_sheen(0.3)
        na2 = narrator('氯化时夺取每个伯氢与仲氢的概率分别为45%/6与55%/2')
        na2[7:9].set_color(TEAL).set_sheen(0.3)
        na2[10:12].set_color(RED).set_sheen(0.3)
        na2[18:21].set_color(GREEN).set_sheen(0.3)
        na2[22].set_color(TEAL).set_sheen(0.3)
        na2[24:27].set_color(GREEN).set_sheen(0.3)
        na2[-1].set_color(RED).set_sheen(0.3)
        self.play(DrawBorderThenFill(na1))
        self.play(cle1[2:4].animate.set_sheen(0.3), cle1[8:10].animate.set_sheen(0.3), run_time=0.5)
        self.play(cle1[2:4].animate.set_color(TEAL), cle1[8:10].animate.set_color(TEAL))
        v1 = VGroup(cle1[2:4].copy(), cle1[8:10].copy())
        self.play(Transform(v1, h1))
        h1n = Text('6').scale(0.6).set_color(TEAL).set_sheen(0.3).next_to(v1, DOWN)
        self.play(Write(h1n))
        self.play(cle1[5:7].animate.set_sheen(0.3), run_time=0.5)
        self.play(cle1[5:7].animate.set_color(RED))
        v2 = cle1[5:7].copy()
        self.play(Transform(v2, h2))
        h2n = Text('2').scale(0.6).set_color(RED).set_sheen(0.3).next_to(v2, DOWN)
        self.play(Write(h2n))
        self.play(Transform(na1, na2))
        self.wait()
        h1m = Text('45%/6').scale(0.6).move_to(h1n)
        h1m[0:3].set_color(GREEN).set_sheen(0.3)
        h1m[-1].set_color(TEAL).set_sheen(0.3)
        vh1 = VGroup(h1n, num1)
        self.play(TransformMatchingShapes(vh1, h1m))
        h2m = Text('55%/2').scale(0.6).move_to(h2n)
        h2m[0:3].set_color(GREEN).set_sheen(0.3)
        h2m[-1].set_color(RED).set_sheen(0.3)
        vh2 = VGroup(h2n, num2)
        self.play(TransformMatchingShapes(vh2, h2m))
        self.wait()
        
        na3 = narrator('2-甲基丙烷中有九个伯氢,一个叔氢')
        na3[10:12].set_color(TEAL).set_sheen(0.3)
        na3[15:17].set_color(PURPLE).set_sheen(0.3)
        na4 = narrator('夺取每个伯氢与叔氢的概率分别为64%/9与36%/1')
        na4[4:6].set_color(TEAL).set_sheen(0.3)
        na4[7:9].set_color(PURPLE).set_sheen(0.3)
        na4[15:18].set_color(GREEN).set_sheen(0.3)
        na4[19].set_color(TEAL).set_sheen(0.3)
        na4[21:24].set_color(GREEN).set_sheen(0.3)
        na4[-1].set_color(PURPLE).set_sheen(0.3)
        self.play(Transform(na1, na3))
        self.play(cle2[40:42].animate.set_sheen(0.3), cle2[45:47].animate.set_sheen(0.3), cle2[48:50].animate.set_sheen(0.3), run_time=0.5)
        self.play(cle2[40:42].animate.set_color(TEAL), cle2[45:47].animate.set_color(TEAL), cle2[48:50].animate.set_color(TEAL))
        v3 = VGroup(cle2[40:42].copy(), cle2[45:47].copy(), cle2[48:50].copy())
        self.play(Transform(v3, h3))
        h3n = Text('9').scale(0.6).set_color(TEAL).set_sheen(0.3).next_to(v3, DOWN)
        self.play(Write(h3n))
        self.play(cle2[43].animate.set_sheen(0.3), run_time=0.5)
        self.play(cle2[43].animate.set_color(PURPLE))
        v4 = cle2[43].copy()
        self.play(Transform(v4, h4))
        h4n = Text('1').scale(0.6).set_color(PURPLE).set_sheen(0.3).next_to(v4, DOWN)
        self.play(Write(h4n))
        self.play(Transform(na1, na4))
        self.wait()
        h3m = Text('64%/9').scale(0.6).move_to(h3n)
        h3m[0:3].set_color(GREEN).set_sheen(0.3)
        h3m[-1].set_color(TEAL).set_sheen(0.3)
        vh3 = VGroup(h3n, num3)
        self.play(TransformMatchingShapes(vh3, h3m))
        h4m = Text('36%/1').scale(0.6).move_to(h4n)
        h4m[0:3].set_color(GREEN).set_sheen(0.3)
        h4m[-1].set_color(PURPLE).set_sheen(0.3)
        vh4 = VGroup(h4n, num4)
        self.play(TransformMatchingShapes(vh4, h4m))
        self.wait()
        self.play(FadeOut(cle1), FadeOut(cle2), FadeOut(na1))
        vv1 = VGroup(v1, h1m)
        vv2 = VGroup(v2, h2m)
        vv3 = VGroup(v3, h3m)
        vv4 = VGroup(v4, h4m)
        self.play(vv1.animate.move_to([-3,2,0]), vv2.animate.move_to([3,2,0]), vv3.animate.move_to([-3,-2,0]), vv4.animate.move_to([3,-2,0]))
        self.play(vv1.animate.scale(1.5), vv2.animate.scale(1.5), vv4.animate.scale(1.5), vv3.animate.scale(1.5))
        m1 = Text('7.5%').scale(0.6).scale(1.5).move_to(h1m).set_color(TEAL).set_sheen(0.3)
        m2 = Text('27.5%').scale(0.6).scale(1.5).move_to(h2m).set_color(RED).set_sheen(0.3)
        m3 = Text('7.1%').scale(0.6).scale(1.5).move_to(h3m).set_color(TEAL).set_sheen(0.3)
        m4 = Text('36.0%').scale(0.6).scale(1.5).move_to(h4m).set_color(PURPLE).set_sheen(0.3)
        z1 = Text('1').scale(0.6).scale(1.5).move_to(h1m).set_color(TEAL).set_sheen(0.3)
        z2 = Text('3').scale(0.6).scale(1.5).move_to(h2m).set_color(RED).set_sheen(0.3)
        z3 = Text('1').scale(0.6).scale(1.5).move_to(h3m).set_color(TEAL).set_sheen(0.3)
        z4 = Text('5').scale(0.6).scale(1.5).move_to(h4m).set_color(PURPLE).set_sheen(0.3)
        self.play(Transform(h1m, m1), Transform(h2m, m2), Transform(h3m, m3), Transform(h4m, m4))
        r1 = Text(':').scale(0.6).scale(1.5).move_to([0,2,0]).set_y(m1.get_y())
        r2 = Text(':').scale(0.6).scale(1.5).move_to([0,-2,0]).set_y(m3.get_y())
        self.play(GrowFromCenter(r1), GrowFromCenter(r2))
        self.wait()
        self.play(Transform(h1m, z1), Transform(h2m, z2), Transform(h3m, z3), Transform(h4m, z4))
        self.play(vv1.animate.move_to([-4.5,0,0]), vv2.animate.move_to([0,0,0]), FadeOut(vv3), vv4.animate.move_to([4.5,0,0]), r1.animate.move_to([-2.25,-0.4,0]), r2.animate.move_to([2.25,-0.4,0]))                                                       
        q1 = narrator('因此,三种氢的反应相对活性大致为1:3:5')
        q1[-5].set_color(TEAL).set_sheen(0.3)                                                                              
        q1[-3].set_color(RED).set_sheen(0.3)                                                                              
        q1[-1].set_color(PURPLE).set_sheen(0.3)                                                                              
        self.play(DrawBorderThenFill(q1))
        self.wait()
        q2 = narrator('以此类推,溴化时三种氢的反应相对活性大致为1:82:1600')
        q2[-4:-1].set_color(PURPLE).set_sheen(0.3)
        q2[-1].set_color(PURPLE).set_sheen(0.3)
        q2[-7:-5].set_color(RED).set_sheen(0.3)
        q2[-9].set_color(TEAL).set_sheen(0.3)
        self.play(Transform(q1, q2))
        self.wait()
        f1 = Text('1').scale(0.6).scale(1.5).move_to(h1m).set_color(TEAL).set_sheen(0.3)
        f2 = Text('82').scale(0.6).scale(1.5).move_to(h2m).set_color(RED).set_sheen(0.3)
        f4 = Text('1600').scale(0.6).scale(1.5).move_to(h4m).set_color(PURPLE).set_sheen(0.3)
        self.play(Transform(h1m, f1), Transform(h2m, f2), Transform(h4m, f4))
        self.wait()
        q3 = narrator('在氯化或溴化反应中,氢的反应相对活性均为伯氢<仲氢<叔氢')
        q3[-1].set_color(PURPLE).set_sheen(0.3)
        q3[-2].set_color(PURPLE).set_sheen(0.3)
        q3[-5:-3].set_color(RED).set_sheen(0.3)
        q3[-8:-6].set_color(TEAL).set_sheen(0.3)
        self.play(Transform(q1, q3))
        i1 = Text('<').match_height(r1).move_to(r1)
        i2 = Text('<').match_height(r2).move_to(r2)
        self.play(Transform(r1, i1), Transform(r2, i2))
        self.wait()
        a1 = narrator('这是因为三种活性中间体自由基的稳定性不同')
        vall = VGroup(r1, r2, vv1, vv2, vv4)
        self.play(Transform(q1, a1), FadeOut(vall))
# --------------------------------------------------------------
        e1 = SVGMobject(r'D:\manimSVG\sigma1.svg').shift(4*LEFT)
        e1[3].set_color(BLUE)
        e1[0].set_color(BLUE)

        e2 = SVGMobject(r'D:\manimSVG\sigma2.svg').scale(1.7).shift(0.3*UP)
        e2[0].set_color(BLUE)
        e2[2].set_color(BLUE)
        e2[4].set_color(BLUE)
        e2[7].set_color(BLUE)
        e2[10].set_color(BLUE)

        zhong = SVGMobject(r'D:\manimSVG\zhong.svg')
        zhong[3].set_color(BLUE)
        zhong[0].set_color(BLUE)
        
        shu = SVGMobject(r'D:\manimSVG\shu.svg').shift(4*RIGHT)
        shu[3].set_color(BLUE)
        shu[0].set_color(BLUE)
        self.play(GrowFromCenter(e2))
        self.wait()
        baseline = DashedLine().set_length(2.1).shift(0.8*UP + 0.2*LEFT)
        a2 = narrator('一级自由基中,C-Hσ键中的一对电子会趋向于')
        a3 = narrator('离域到相邻含单电子的p轨道上')
        a4 = narrator('这样电荷得到分散,体系更加稳定')
        self.play(Transform(q1,a2))
        self.wait()
        self.play(Transform(q1,a3), Write(baseline))
        self.wait()
        self.play(Transform(q1,a4))
        self.wait()
        self.play(FadeOut(baseline), FadeOut(e2))
        self.play(GrowFromCenter(e1), GrowFromCenter(zhong), GrowFromCenter(shu))
        p1 = narrator('一级自由基中参与σ-p超共轭的C-Hσ键个数为3')
        p1[-1].set_color(TEAL).set_sheen(0.3)
        p2 = narrator('二级自由基为6')
        p2[-1].set_color(RED).set_sheen(0.3)
        p3 = narrator('三级自由基为9')
        p3[-1].set_color(PURPLE).set_sheen(0.3)
        self.wait()
        self.play(Transform(q1,p1))
        self.play(e1[18:29].animate.set_sheen(0.3), run_time=0.5)
        self.play(e1[18:29].animate.set_color(TEAL))
        self.wait()
        self.play(Transform(q1,p2))
        self.play(zhong[20:31].animate.set_sheen(0.3), zhong[10:12].animate.set_sheen(0.3), run_time=0.5)
        self.play(zhong[20:31].animate.set_color(RED), zhong[10:12].animate.set_color(RED))
        self.wait()
        self.play(Transform(q1,p3))
        self.play(shu[23:34].animate.set_sheen(0.3), shu[14:16].animate.set_sheen(0.3), shu[10:12].animate.set_sheen(0.3), run_time=0.5)
        self.play(shu[23:34].animate.set_color(PURPLE), shu[14:16].animate.set_color(PURPLE), shu[10:12].animate.set_color(PURPLE))
        self.wait()
        p4 = narrator('参与超共轭的C-Hσ键个数越多,电荷越分散,体系越稳定')
        p5 = narrator('故活性中间体自由基的稳定性顺序为一级<二级<三级')
        p5[-1].set_color(PURPLE).set_sheen(0.3)
        p5[-2].set_color(PURPLE).set_sheen(0.3)
        p5[-5:-3].set_color(RED).set_sheen(0.3)
        p5[-8:-6].set_color(TEAL).set_sheen(0.3)
        p6 = narrator('因此在氯化或溴化反应中,氢的反应相对活性均为伯氢<仲氢<叔氢')
        p6[-1].set_color(PURPLE).set_sheen(0.3)
        p6[-2].set_color(PURPLE).set_sheen(0.3)
        p6[-5:-3].set_color(RED).set_sheen(0.3)
        p6[-8:-6].set_color(TEAL).set_sheen(0.3)

        self.play(Transform(q1,p4))
        self.wait()
        self.play(Transform(q1,p5))
        self.wait()
        self.play(Transform(q1,p6))
        self.wait()
        v1.move_to(np.array([-4.5,0,0]))
        v2.move_to(np.array([0,0,0]))
        v4.move_to(np.array([4.5,0,0]))
        i1.move_to(np.array([-2.25,0,0]))
        i2.move_to(np.array([2.25,0,0]))
        self.play(Transform(e1, v1), Transform(zhong, v2), Transform(shu, v4))
        self.play(FadeIn(i1), FadeIn(i2))
        self.wait()
        vall = VGroup(q1, e1, zhong, shu, i1, i2)
        self.play(Transform(vall, t3c))
        self.play(FadeIn(vgfadeout))
        self.wait()
        self.play(FadeOut(vgfadeout), FadeOut(vall))
        self.wait()

 

标签:play,set,color,self,Halogenation,alkanes,0.3,sheen
来源: https://www.cnblogs.com/daxiangcai/p/16484674.html