%%manim -v WARNING -qh s1
class s1(Scene):
def construct(self):
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)
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))
def addnumber(l, svg):
n = 1
vg = VGroup()
for i in l:
num = Integer(number=n).scale(0.7).set_color(BLUE).next_to(svg[i], 0.5*DOWN)
vg.add(num)
n += 1
return vg
def getall():
all = self.mobjects
vg = VGroup()
for i in all:
vg.add(i)
return vg
t0 = Text('烃衍生物的系统命名',font="STZhongsong")
self.play(DrawBorderThenFill(t0))
notation = narrator('*此视频使用2017版有机化合物命名原则')
self.play(FadeIn(notation))
self.wait(1)
self.play(FadeOut(t0), FadeOut(notation))
a0 = narrator('烃分子中的氢被官能团取代后的化合物称为烃的衍生物')
m1 = MarkupText('CH<sub>3</sub>CH<sub>3</sub>')
m2 = MarkupText('CH<sub>3</sub>CH<sub>2</sub><span foreground="#32CD32">Cl</span>')
m3 = MarkupText('CH<sub>3</sub>CH<sub>2</sub><span foreground="#5599FF">COOH</span>')
m4 = MarkupText('CH<sub>3</sub>CH<sub>2</sub><span foreground="#9955FF">CHO</span>')
self.play(DrawBorderThenFill(a0),DrawBorderThenFill(m1))
self.play(TransformMatchingShapes(m1,m2))
self.wait(0.5)
self.play(TransformMatchingShapes(m2,m3))
self.wait(0.5)
self.play(TransformMatchingShapes(m3,m4))
self.wait(0.5)
self.play(FadeOut(m4),FadeOut(a0))
l1 = Text('单官能团化合物的系统命名',font="STZhongsong")
l2 = Text('含多个相同官能团化合物的系统命名',font="STZhongsong")
l3 = Text('含多种官能团化合物的系统命名',font="STZhongsong")
self.play(DrawBorderThenFill(l1))
self.play(FadeOut(l1))
a0 = narrator('单官能团化合物的系统命名有两种情况,第一种情况是将官能团作为取代基')
a1 = narrator('仍以烷烃为母体,按烷烃的命名原则来命名')
a2 = narrator('当官能团是卤素、硝基、亚硝基时,采用这种方法来命名,例如:')
q1 = SVGMobject(r'D:\manimSVG\q1.svg')
self.play(DrawBorderThenFill(a0),DrawBorderThenFill(q1))
self.wait(1)
self.play(Transform(a0,a1))
self.wait(1)
self.play(Transform(a0,a2))
self.wait(1)
self.play(FadeOut(a0))
numlist = addnumber([2,5,8,10,13], q1)
self.play(FadeIn(numlist))
m1 = Text('1-溴-3-甲基戊烷',font="STZhongsong").scale(0.7).next_to(q1,3*DOWN)
m1[8:10].set_color(GREEN_C)
m1[3:8].set_color(color='#9955FF')
m1[0:3].set_color(PINK)
self.play(q1[2:16].animate.set_color(GREEN_C))
self.wait(0.6)
q1c = q1[2:16].copy()
self.play(Transform(q1c,m1[8:10]))
self.wait(0.6)
self.play(q1[16:20].animate.set_color(color='#9955FF'))
self.wait(0.6)
q2c = q1[16:20].copy()
self.play(Transform(q2c,m1[3:8]))
self.wait(0.6)
self.play(q1[0:2].animate.set_color(PINK))
self.wait(0.6)
q3c = q1[0:2].copy()
self.play(Transform(q3c,m1[0:3]))
vgc = VGroup(q1c,q2c,q3c)
ename = Text('1-bromo-3-methylpentane').scale(0.7).next_to(vgc,DOWN)
ename[0:7].set_color(PINK)
ename[7:16].set_color(color='#9955FF')
ename[16:23].set_color(GREEN_C)
self.play(FadeIn(ename))
self.wait(1)
self.play(FadeOut(vgc),FadeOut(numlist),FadeOut(ename))
q2 = SVGMobject(r'D:\manimSVG\q2.svg')
self.play(Transform(q1,q2))
self.add(q2)
self.remove(q1)
numlist = addnumber([0,3,5], q2)
self.play(FadeIn(numlist))
m2 = Text('2-硝基丙烷',font="STZhongsong").scale(0.7).next_to(q2,3*DOWN)
m2[4:6].set_color(GREEN_C)
m2[0:4].set_color(color='#9955FF')
self.wait(0.5)
self.play(q2[0:8].animate.set_color(GREEN_C))
q1c = q2[0:8].copy()
self.wait(0.6)
self.play(Transform(q1c,m2[4:6]))
self.wait(0.6)
self.play(q2[8:12].animate.set_color(color='#9955FF'))
q2c = q2[8:12].copy()
self.wait(0.6)
self.play(Transform(q2c,m2[0:4]))
vgc = VGroup(q1c,q2c)
ename = Text('2-nitropropane').scale(0.7).next_to(vgc,DOWN)
ename[0:7].set_color(color='#9955FF')
ename[7:].set_color(GREEN_C)
self.play(FadeIn(ename))
self.wait(1)
self.play(FadeOut(vgc),FadeOut(numlist), FadeOut(q2), FadeOut(ename))
a0 = narrator('若官能团是醚键,也可以采用这种方式来命名')
a1 = narrator('取较长的烃基作为母体,把余下的碳数较少的烷氧基作取代基')
q3 = SVGMobject(r'D:\manimSVG\q3.svg').scale(0.25)
m0 = Text('1,2-二甲氧基乙烷',font="STZhongsong").next_to(q3, 3*DOWN).scale(0.7)
m0[8:10].set_color(GREEN_C)
m0[0:8].set_color(color='#9955FF')
self.play(DrawBorderThenFill(a0),DrawBorderThenFill(q3))
self.wait(1)
self.play(Transform(a0,a1))
self.wait(1)
self.play(FadeOut(a0))
nl = addnumber([4,7], q3)
self.play(FadeIn(nl))
self.wait(0.6)
self.play(q3[4:10].animate.set_color(GREEN_C))
self.wait(0.6)
c1 = q3[4:10].copy()
self.play(Transform(c1,m0[8:10]))
self.wait(0.6)
self.play(q3[0:4].animate.set_color(color='#9955FF'))
self.wait(0.6)
self.play(q3[10:14].animate.set_color(color='#9955FF'))
self.wait(0.6)
c2 = VGroup(q3[0:4].copy(), q3[10:14].copy())
vc = VGroup(c1,c2)
self.play(Transform(c2,m0[0:8]))
ename = Text('1,2-dimethoxyethane').scale(0.7).next_to(vc,DOWN)
ename[0:13].set_color(color='#9955FF')
ename[13:].set_color(GREEN_C)
self.play(FadeIn(ename))
self.wait(1)
self.play(FadeOut(vc),FadeOut(nl),FadeOut(q3),FadeOut(ename))