Rearrangement of carbopositive ions
作者:互联网
functions
# xxp if type('xxp') == str: # xxp transform def xt(names, *args): def pretrans0(name, i): if type(i) == int: back = name + '[' + str(i) + ']' elif type(i) == str: m = i.find('.') n1 = i[0:m] n2 = i[m+1:] back = name + '[' + n1 + ':' + n2 + ']' return back def pretrans(name, i): if type(i) == int: back = name + '[' + str(i) + ']' elif type(i) == str: m = i.find('.') n1 = i[0:m] n2 = i[m+1:] back = name + '[' + n1 + ':' + n2 + ']' elif type(i) == list: back = 'VGroup(' for j in i: item = pretrans0(name, j) + ',' back += item back += ')' return back ag = 'AnimationGroup(' # range(0, n-1)是错的 itemli = [] for l in names: itemli.append(list(range(len(l)))) def countli0(name, i): if type(i) == int: name.remove(i) elif type(i) == str: m = i.find('.') n1 = int(i[0:m]) n2 = int(i[m+1:])-1 p1 = name.index(n1) p2 = name.index(n2) del name[p1:p2+1] def countli(name, i): if type(i) == int: name.remove(i) elif type(i) == str: m = i.find('.') n1 = int(i[0:m]) n2 = int(i[m+1:])-1 p1 = name.index(n1) p2 = name.index(n2) del name[p1:p2+1] elif type(i) == list: for j in i: item = countli0(name, j) set1 = set() set2 = set() for m in range(len(args)): n = 0 for i in args[m][2]: n += 1 if n % 2 != 0: u = pretrans(f'names[args[{str(m)}][0]]', i) countli(itemli[args[m][0]], i) set1.add(args[m][0]) else: v = pretrans(f'names[args[{str(m)}][1]]', i) item = f'Transform({u}, {v}),' ag += item countli(itemli[args[m][1]], i) set2.add(args[m][1]) for i in set1: for ii in itemli[i]: # reverse GrowFromCenter不可用 ag += f'ShrinkToCenter(names[{str(i)}][{str(ii)}]), ' for j in set2: for jj in itemli[j]: ag += f'GrowFromCenter(names[{str(j)}][{str(jj)}]), ' ag += ')' agg = eval(ag) return agg # xxp transform 2 def xt2(a, b, c): def pretrans0(name, i): if type(i) == int: back = name + '[' + str(i) + ']' elif type(i) == str: m = i.find('.') n1 = i[0:m] n2 = i[m+1:] back = name + '[' + n1 + ':' + n2 + ']' return back def pretrans(name, i): if type(i) == int: back = name + '[' + str(i) + ']' elif type(i) == str: m = i.find('.') n1 = i[0:m] n2 = i[m+1:] back = name + '[' + n1 + ':' + n2 + ']' elif type(i) == list: back = 'VGroup(' for j in i: item = pretrans0(name, j) + ',' back += item back += ')' return back n = 0 ag = 'AnimationGroup(' # range(0, n-1)是错的 for i in c: n += 1 if n % 2 != 0: u = pretrans('a', i) else: v = pretrans('b', i) item = f'Transform({u}, {v}),' ag += item ag += ')' agg = eval(ag) return agg # xxp transform 3 def xt3(a,b): x=b.get_center()-a.get_center() y=b.width/a.width return AnimationGroup(a.animate.shift(x).scale(y)) # xxp color to hex def xc2h(c): return rgb_to_hex(color_to_rgb(c)) # xxp opacity scale def xos(inter, num, *args): # 最好让透明度也一样 def premovescale(a, b): # x = VGroup() # y = VGroup() for i in a: # 设置get_fill_opacity() == 0.5会失效 if i.get_fill_opacity() < 1: x = i # x.add(i) for j in b: if j.get_fill_opacity() < 1: y = j # y.add(j) scale = y.height/x.height a.scale(scale) # 先缩放再移动 vector = y.get_center() - x.get_center() a.shift(vector) if inter == 1: for n in range(len(args)): if n == 0: premovescale(args[n], Text('H', font='Times New Roman', fill_opacity=0.5).scale(num)) args[n].move_to(ORIGIN) else: premovescale(args[n], args[n-1]) if inter == 2: for n in range(len(args) - 1): premovescale(args[n+1], args[n]) # xxp color and opacity init def xcoi(*args): for a in args: # 先缩放再设置透明度(否则会消失不见) a.set_opacity(1) for i in a: if xc2h(i.color) == '#ff0000': i.set_color(RED).set_sheen(0.1) elif xc2h(i.color) == '#ffff00': i.set_color(GOLD).set_sheen(0.1) elif xc2h(i.color) == '#00ff00': i.set_color(GREEN).set_sheen(0.1) elif xc2h(i.color) == '#00ffff': i.set_color(TEAL).set_sheen(0.1) elif xc2h(i.color) == '#0000ff': i.set_color(BLUE).set_sheen(0.1) elif xc2h(i.color) == '#ff00ff': i.set_color(PINK).set_sheen(0.1) # xxp check def xc(*args): self.camera.background_color = WHITE for svg in args: if type(svg) == list: self.clear() for sss in svg: self.add(sss.set(color = RED)) for sss in svg: n = 0 for i in sss: num = Integer(number=n, stroke_width=2).set_color(BLACK).move_to(i) n += 1 self.add(num) self.wait() else: self.clear() self.add(svg.set(color = RED)) n = 0 for i in svg: num = Integer(number=n, stroke_width=2).set_color(BLACK).move_to(i) n += 1 self.add(num) self.wait() self.clear() # xxp align def xa(b, a): l = len(a) for i in range(0, l): b[i].set_x(a[i].get_x()) if i > 0: b[i].set_y(b[0].get_y()) # xxp find def xf(a, b): n1 = str.find(a.text, b) n2 = n1 + len(b) return a[n1:n2] # xxp narrator def xn(a): text = Text(a, font='STZhongsong').to_edge(DOWN).scale(0.6) return text # xxp narrator fangsong def xnf(a): text = Text(a, font='STFangsong').scale(0.7).to_edge(DOWN) return text # xxp upnarrator def xun(a): text = Text(a, font='STZhongsong').to_edge(UP).scale(0.8) return text # xxp para def xp(x, y): a = Text(y, font="STZhongsong").to_edge(DOWN).scale(0.6) b = Text(x, font="STZhongsong").to_edge(1.8*DOWN).scale(0.6) return VGroup(a, b) # xxp scale def xs(a, n1, b, n2): scale = b[n2].width/a[n1].width a.scale(scale) # xxp move def xm(a, n1, b, n2): vect = b[n2].get_center() - a[n1].get_center() a.shift(vect) # xxp move and scale def xms(a, n1, b, n2): scale = b[n2].width/a[n1].width a.scale(scale) vect = b[n2].get_center() - a[n1].get_center() a.shift(vect) # xxp choose color def xcc(a, b): for i in a: if rgb_to_hex(color_to_rgb(i.color)) == b: return i # xxp narrator wait def xnw(a): self.wait(0.1*len(a)) # xxp text flower def xtf(a): at = Text(a, font = 'STZhongsong',stroke_width=2).set_color(color = ['#f3e9e0', '#fea8a9']) # at[0].set_color(color = ['#f3e9e0', '#fea8a9']) # at[1].set_color(color = ['#f3e9e0', '#fea8a9']) fl = msm('icon')[8].rotate(PI/2).set_color(color = ['#fea8a9', '#f3e9e0']).scale(1.5) at.next_to(fl, RIGHT) vg = VGroup(fl, at) vg.set(height = 0.6).to_corner(UL) return vg # xxp text flower2 def xtf2(judge, a): if judge == 1: at = Text(a, font = 'STFangsong',stroke_width=2).set_color(color = ['#f3e9e0', '#b1d85c']) elif judge == 2: # 一般不是中文 at = MarkupText(a, stroke_width=2).set_color(color = ['#f3e9e0', '#b1d85c']) # at[0].set_color(color = ['#f3e9e0', '#fea8a9']) # at[1].set_color(color = ['#f3e9e0', '#fea8a9']) fl = msm('icon')[8].rotate(PI/2).set_color(color = ['#b1d85c', '#f3e9e0']).scale(1.5) at.next_to(fl, RIGHT) vg = VGroup(fl, at) vg.set(height = 0.6).to_corner(UL).shift(2*RIGHT) return vg # xxp text flower3 def xtf3(a): at = Text(a, font = 'STZhongsong',stroke_width=2).set_color(color = ['#ccffff', '#afccff']) # at[0].set_color(color = ['#f3e9e0', '#fea8a9']) # at[1].set_color(color = ['#f3e9e0', '#fea8a9']) fl = msm('icon')[8].rotate(PI/2).set_color(color = ['#afccff', '#ccffff']).scale(1.5) at.next_to(fl, RIGHT) vg = VGroup(fl, at) vg.set(height = 0.6).to_corner(UL).shift(2*DOWN) return vg # xxp color move and scale def xcms(a, b): x = VGroup() y = VGroup() for i in a: if rgb_to_hex(color_to_rgb(i.color)) == '#000000': x.add(i) for j in b: if rgb_to_hex(color_to_rgb(j.color)) == '#000000': y.add(j) scale = y.width/x.width vect = y.get_center() - x.get_center() a.shift(vect) a.scale(scale) # xxp single scale def xss(a, n): x = Text('C', font="Times New Roman") y = a[n] scale = x.width/y.width a.scale(scale) # xxp pre postion def xpp(a, pos): d1 = Dot().to_corner(UL) d2 = Dot().to_edge(UP) d3 = Dot().to_corner(UR) d4 = Dot().to_edge(LEFT) d5 = Dot() d6 = Dot().to_edge(RIGHT) d7 = Dot().to_corner(DL) d8 = Dot().to_edge(DOWN) d9 = Dot().to_corner(DR) if pos == 'ul': a.move_to((d1.get_center() + d5.get_center())/2) elif pos == 'u': a.move_to((d2.get_center() + d5.get_center())/2) elif pos == 'ur': a.move_to((d3.get_center() + d5.get_center())/2) elif pos == 'l': a.move_to((d4.get_center() + d5.get_center())/2) elif pos == 'o': a.move_to(d5.get_center()) elif pos == 'r': a.move_to((d6.get_center() + d5.get_center())/2) elif pos == 'dl': a.move_to((d7.get_center() + d5.get_center())/2) elif pos == 'd': a.move_to((d8.get_center() + d5.get_center())/2) elif pos == 'dr': a.move_to((d9.get_center() + d5.get_center())/2) # xxp arrange and align def xaa(mobs, b, d): vg = VGroup() for m in mobs: vg.add(m) vg.arrange(buff=b) if d == 'u': dire = UP elif d == 'd': dire = DOWN for i in mobs: if i != mobs[0]: i.align_to(mobs[0], dire) # xxp add other def xao(*args): if len(args) == 2: sa(args[0].to_corner(UR), args[1].to_corner(DL)) if len(args) == 3: sa(args[0].to_corner(UR), args[1].to_corner(DL), args[2].to_corner(DR)) # xxp grow from center def xgf(a, li): avg = 'AnimationGroup(' def pregrow(name, i): if type(i) == int: back = name + '[' + str(i) + ']' elif type(i) == str: m = i.find('.') n1 = i[0:m] n2 = i[m+1:] back = name + '[' + n1 + ':' + n2 + ']' return back for j in li: partani = pregrow('a', j) avg += f'GrowFromCenter({partani}), ' avg += ')' return eval(avg) # xxp reverse grow from center def xrgf(a, li): avg = 'AnimationGroup(' def pregrow(name, i): if type(i) == int: back = name + '[' + str(i) + ']' elif type(i) == str: m = i.find('.') n1 = i[0:m] n2 = i[m+1:] back = name + '[' + n1 + ':' + n2 + ']' return back for j in li: partani = pregrow('a', j) avg += f'GrowFromCenter({partani}, reverse_rate_function = True), ' avg += ')' return eval(avg) # xxp color and sheen static def xcss(a, b): a.set_color(b).set_sheen(0.1) # xxp place in line def xpl(*args): vg = VGroup() frame = FullScreenRectangle() wid = frame.width for i in args: vg.add(i.copy()) wid -= i.width mybuff = wid/(len(args)+1) vg.arrange(buff=mybuff) for j in range(len(args)): args[j].match_x(vg[j]) # xxp place in grid def xpg(*args): n = 0 full = FullScreenRectangle() li = ['ul','ur','dl','dr'] for a in args: if a.width > a.height: a.set(width = full.width/3) xpp(a,li[n]) else: a.set(height = full.height/3) xpp(a,li[n]) n += 1 # xxp color 1 def xc1(*args): for a in args: a.save_state() a.set_color(WHITE).set_sheen(0) # xxp color 2 def xc2(*args): li = [] for a in args: li.append(Restore(a)) return self.play(*li) # xxp color 3 def xc3(*args): li = [] for a in args: li.append(a.animate.set_color(WHITE)) return self.play(*li) # xxp animations list def xal(t,*argss): args = [] for i in argss: args.append(i) # 不是args = atgs.reverse() args.reverse() n = 0 for a in args: if n == 1: ag = AnimationGroup(args[1],args[0],lag_ratio=t) elif n > 1: ag = AnimationGroup(a,ag,lag_ratio=t) n += 1 return ag # xxp sub number def xsn(*args): vg = VGroup() for i in range(len(args)): n = Integer(i+1).next_to(args[i],0.7*UP) xcss(n, BLUE) vg.add(n) return vg # xxp get distance def xgd(a,b): return b.get_center() - a.get_center() # xxp get distance by codrdinate def xgdc(a,b): return b - a.get_center() # xxp text flower list def xtfl(a,*args): # for a in args: vg = VGroup() li0 = xtf(a) vg.add(li0) n = 1 for a in args: li = xtf2(1,a) xm(li,0,li0,0);li.shift(n*0.9*DOWN+RIGHT) vg.add(li) n += 1 return vg # xxp text flower list abbr def xtfla(a,b): # for a in args: vg = VGroup() li0 = xtf(a) n = 1 li1 = xtf2(1,'');xm(li1,0,li0,0);li1.shift(DOWN+RIGHT) vg.add(li0,li1) for i in range(b-1): li = xtf2(1,'') xm(li,0,li1,0);li.shift(n*0.2*DOWN) vg.add(li) n += 1 return vg # xxp corner check def xcc(a,b): a.to_corner(UL);b.to_corner(DR) xc([a,b]) # xxp edge check def xec(a,b): a.to_edge(UP);b.to_edge(DOWN) xc([a,b]) # xxp grid check def xgc(*args): xpg(*args) xc([*args]) # xxp orbit color def xoc(a): a.set_color([BLUE_C, BLUE_E]).set_sheen(0.3).set_opacity(0.8) # manim CE if type('manim CE') == str: # self.play() def sp(*args, **kwargs): return self.play(*args, **kwargs) # self.wait() def sw(*args, **kwargs): return self.wait(*args, **kwargs) # self.add() def sa(*args, **kwargs): return self.add(*args, **kwargs) # self.clear() def sc(*args, **kwargs): return self.clear(*args, **kwargs) # self.remove() def sr(*args, **kwargs): return self.remove(*args, **kwargs) # Animation Transform() def at(a, b, *args, **kwargs): return Transform(a, b, *args, **kwargs) # Animation ReplacementTransform() def art(a, b, *args, **kwargs): return ReplacementTransform(a, b, *args, **kwargs) # Animation TransformMatchingShapes() def atm(a, b, *args, **kwargs): return TransformMatchingShapes(a, b, *args, **kwargs) # Animation ClockwiseTransform() def act(a, b, *args, **kwargs): return ClockwiseTransform(a, b, *args, **kwargs) # Animation CounterclockwiseTransform() def acct(a, b, *args, **kwargs): return CounterclockwiseTransform(a, b, *args, **kwargs) # Animation Write() def aw(a, *args, **kwargs): return Write(a, *args, **kwargs) # Animation LaggedStart() def als(a, *args, **kwargs): return LaggedStart(a, *args, **kwargs) # Animation Unwrite() def auw(a, *args, **kwargs): return Unwrite(a, *args, **kwargs) # Animation FadeOut() def afo(a, *args, **kwargs): return FadeOut(a, *args, **kwargs) # Animation FadeIn() def afi(a, *args, **kwargs): return FadeIn(a, *args, **kwargs) # Animation Restore() def ar(a, *args, **kwargs): return Restore(a, *args, **kwargs) # Animation DrawBorderThenFill() def adb(a, *args, **kwargs): return DrawBorderThenFill(a, *args, **kwargs) # Animation DrawBorderThenFill() reverse def adbr(a, *args, **kwargs): return DrawBorderThenFill(a, *args, **kwargs, reverse_rate_function = True) # Animation GrowFromCenter() def agf(a, *args, **kwargs): return GrowFromCenter(a, *args, **kwargs) # Animation MoveAlongPath() def ama(a, b, *args, **kwargs): return MoveAlongPath(a, b, *args, **kwargs) # Animation SpinInFromNothing def asi(a, *args, **kwargs): return SpinInFromNothing(a, angle=2 * PI, *args, **kwargs) # Animation SpinInFromNothing reverse def asir(a, *args, **kwargs): return SpinInFromNothing(a, angle=2 * PI, *args, **kwargs, reverse_rate_function = True) # Animation ShrinkToCenter def ast(a, *args, **kwargs): return ShrinkToCenter(a, *args, **kwargs) # Animation Circumscribe def ac(a, *args, **kwargs): return Circumscribe(a, *args, **kwargs) # Animation Indicate def ai(a, *args, **kwargs): return Indicate(a, *args, **kwargs) # Group sheen def gs(*args): li = [] for i in args: li.append(i.animate.set_sheen(0.1)) return AnimationGroup(*li, run_time=0.5) # Group color def gc(*args): li = [] for i in range(len(args)): if i % 2 == 0: li.append(args[i].animate.set_color(args[i+1])) return AnimationGroup(*li) # mobject Text def mt(text, *args, **kwargs): return Text(text, *args, **kwargs) # mobject SVGMobject def msm(name, *args, **kwargs): sm = SVGMobject(f'D:\\manimSVG\\{name}.svg') return sm # mobject MathTex def mmt(text, *args, **kwargs): return MathTex(text, *args, **kwargs) # mobject VGroup def mvg(*args, **kwargs): return VGroup(*args, **kwargs) # mobject ArcBetweenPoints def mab(a, b, *args, **kwargs): return ArcBetweenPoints(a.get_center(), b.get_center(), *args, **kwargs) # other function if type('other function') == str: # refresh def refresh(*args, **kwargs): sc() sa(*args, **kwargs) # color refresh def crefresh(*args, **kwargs): sc() for i in args: xcoi(i) sa(*args, **kwargs)View Code
scene1~5
def playscene1(): t0=mt('碳正离子的重排',font='STZhongsong');t1=xn('重排指的是分子内骨架的重组、形成新的骨架的过程');t2=xn('重排反应可以根据Y的移动位点来分类');t3=xn('例如,此时为1,2-重排');t4=xn('此时为1,3-重排');xcss(t3[6:9],BLUE);xcss(t4[3:6],BLUE) t5=xn('也可以按迁移始点和终点的元素进行分类') u1=xun('重排基团');xcss(u1,BLUE);u2=xun('重排起点原子');xcss(u2,RED);u3=xun('重排终点原子');xcss(u3,GREEN);u4=xun('*这里只讨论分子内的重排反应');u5=xun('由碳至碳的重排反应');xcss(u5[1],RED);xcss(u5[3],BLUE) u6=xun('由碳至氮的重排反应');xcss(u6[1],RED);xcss(u6[3],BLUE);u7=xun('由碳至氧的重排反应');xcss(u7[1],RED);xcss(u7[3],BLUE) a1=msm("a1");a2=msm("a2");a3=msm("a3");a4=msm("a4");a5=msm("a5");xos(1,a1,a2,a3,a4,a5);xs(a5,15,a1,0);a5.move_to(ORIGIN).scale(0.9);c1=a1[5:10].copy().move_to(a1[1:5]) n1=xsn(a1[1],a1[3]);n2=xsn(a1[5],a1[6]);n3=xsn(a5[11],a5[0],a5[1]);n4=xsn(a5[13],a5[3],a5[4]);a1.save_state() w1=Text('C',font='Times New Roman');xcss(w1,RED);xms(w1,0,a1,1);w2=w1.copy();w2.move_to(a1[5]);w3=w1.copy();w3.move_to(a1[3]);w4=w1.copy();w4.move_to(a1[6]);xcss(w2,RED);xcss(w3,BLUE);xcss(w4,BLUE); w5=Text('N',font='Times New Roman');xs(w5,0,w1,0);w5.move_to(a1[3]);w6=w5.copy();w6.move_to(a1[6]);xcss(w5,BLUE);xcss(w6,BLUE);w7=Text('O',font='Times New Roman');xs(w7,0,w1,0);w7.move_to(a1[3]);w8=w7.copy();w8.move_to(a1[6]);xcss(w7,BLUE);xcss(w8,BLUE); sp(adb(t0));sp(afo(t0)) sp(afi(t1));sp(afi(a1,shift=2*DOWN));sw();sp(a1[5:10].animate.set_opacity(0.3));sw();sp(als(atm(a1[0:5],c1)));sw();sp(c1.animate.move_to(a1[5:10]));sp(afi(a1[0:5]));a1[5:10].set_opacity(1);refresh(t1,a1);sw();sp(afi(u4));sw();sp(afo(u4)) sp(afo(t1),gc(a1[0],BLUE,a1[8],BLUE),afi(u1));sp(gs(a1[0],a1[8]));sw();sp(gc(a1[0],WHITE,a1[8],WHITE),gc(a1[1],RED,a1[5],RED),afi(u2),afo(u1));sp(gs(a1[1],a1[5]));sw() sp(gc(a1[1],WHITE,a1[5],WHITE),gc(a1[3],GREEN,a1[6],GREEN),afi(u3),afo(u2));sp(gs(a1[3],a1[6]));sw();sp(gc(a1[3],WHITE,a1[6],WHITE),afo(u3)) sp(afi(t2));sw(2);sp(at(t2,t3));sp(afi(n1,n2));sw(2);sp(xt([a1,a5],[0,1,[0,15,2,16,1,[11,0],4,2,3,1,'10.13','8.11',5,[3,13],7,5,6,4,9,7,8,6]]),xt([n1,n3,n2,n4],[0,1,[0,'0.2',1,2]],[2,3,[0,'0.2',1,2]])) sp(at(t2,t4));sw(2);sp(ar(a1),ast(a5[12]),ast(a5[14]),afo(n1,n2));sp(at(t2,t5),gc(a1[1],RED,a1[3],BLUE,a1[5],RED,a1[6],BLUE));sp(gs(a1[1],a1[3],a1[5],a1[6]));sw(2);sp(afo(t2)) sp(at(a1[1],w1),at(a1[5],w2),at(a1[3],w3),at(a1[6],w4),afi(u5,shift=DOWN));sw();sp(at(a1[3],w5),at(a1[6],w6),afi(u6,shift=DOWN),afo(u5,shift=DOWN));sw();sp(at(a1[3],w7),at(a1[6],w8),afi(u7,shift=DOWN),afo(u6,shift=DOWN)) sw();sp(afo(u7),ar(a1));sw(0.5) def playscene2(): a1=msm("a1");a2=msm("a2");a3=msm("a3");a4=msm("a4");xos(1,a1,a2,a3,a4,);xcoi(a1,a2,a3,a4);cb=a1[9].copy() u1=xun('亲核重排:Y具有亲核性,带有一对电子迁移') u2=xun('亲电重排:Y具有亲电性,以正离子的方式迁移') u3=xun('自由基重排:Y以自由基的方式迁移') t1=xn('也可以根据B—Y键的断裂方式来分类');xcss(t1[5:9],BLUE) t2=xn('此外,还有些重排通过协同的环状过渡态方式进行') t3=xn('称为协同重排') sa(a1);sw(0.5);sp(afi(t1));sw(2);sp(afo(a1[5:10]),afo(t1));a2[4:9].set_opacity(0);a2[15].set_opacity(0);a1[5:10].set_opacity(0);sp(gc(a1[2],BLUE));sp(gs(a1[2]));a1.save_state() sp(xt([a1,a2],[0,1,[0,0,2,'13.15',1,1,4,3,3,2,'10.13','9.12']]));refresh(a2);sp(afi(u1,shift=DOWN));sw(2);sp(mvg(a2[1:4],a2[12:14]).animate.shift(xgd(a2[5],a2[2])),mvg(a2[0],a2[14]).animate.shift(xgd(a2[7],a2[0])));sw();xcss(cb,BLUE);sp(at(mvg(a2[14],a2[12]),cb));sw(1.5) a1.restore();sp(afo(a2),afi(a1));sp(afi(u2,shift=DOWN),afo(u1,shift=DOWN));sw(2) a3[4:9].set_opacity(0);a3[15].set_opacity(0) sp(xt([a1,a3],[0,1,[0,0,2,'12.14',1,1,4,3,3,2,'10.13','9.12']]));refresh(a3,u2);sp(mvg(a3[1:4],a3[13:15]).animate.shift(xgd(a3[5],a3[2])),mvg(a3[0],a3[12]).animate.shift(xgd(a3[7],a3[0])));sw();xcss(cb,WHITE);sp(at(mvg(a3[14],a3[12]),cb));sw(1.5) a1.restore();sp(afo(a3),afi(a1));sp(afi(u3,shift=DOWN),afo(u2,shift=DOWN));sw(2) a4[4:9].set_opacity(0);a4[15].set_opacity(0) sp(xt([a1,a4],[0,1,[0,0,2,'12.14',1,1,4,3,3,2,'10.13','9.12']]));refresh(a4,u3);sp(mvg(a4[1:4],a4[13:15]).animate.shift(xgd(a4[5],a4[2])),mvg(a4[0],a4[12]).animate.shift(xgd(a4[7],a4[0])));sw();xcss(cb,BLUE);sp(at(mvg(a4[14],a4[12]),cb));sw(1.5) a1.restore();a1.set_opacity(1).set_color(WHITE);sp(afo(a4),afi(a1));sp(afo(u3,shift=DOWN));sp(afi(t2));sw(2);sp(at(t2,t3));sw();sp(afo(a1,t2));sw(0.5) def playscene3(): f1 = xtfl('由碳至碳的重排反应','Wagner-Meerwein 重排','Pinacol 重排','Demyanov和Tiffen-Demyanov 重排','Dienone-phenol 重排','Allylic 重排','Benzilic acid 重排','Acid-catalyzed Aldehyde-Ketone 重排') f2 = xtfl('由碳至碳的重排反应(碳烯重排)','Wolff 重排和Arndt-Eistert 合成','其他碳烯重排') f3 = xtfl('由碳至氮的重排反应','Beckmann 重排','Hofmann 重排','Curtius 重排','Schmidt 重排','Lossen 重排','Neber 重排') f4 = xtfl('由碳至氧的重排反应','Hydeoperoxide 重排','Baeyer-Villiger 反应') v1 = xtfla('由碳至碳的重排反应',7);v1.shift(xgdc(v1[0][0],[-6,2.5,0])) v2 = xtfla('由碳至碳的重排反应(碳烯重排)',2);v2[0][1].scale(0.8);v2[0][1].next_to(v2[0][0],RIGHT);v2.shift(xgdc(v2[0][0],[0,2.5,0])) v3 = xtfla('由碳至氮的重排反应',6);v3.shift(xgdc(v3[0][0],[-6,-0.5,0])) v4 = xtfla('由碳至氧的重排反应',2);v4.shift(xgdc(v4[0][0],[0,-0.5,0])) t1 = xn('其中最常见的重排方式为亲核重排') t2 = xn('常见的亲核重排反应有:') t3 = xn('这里详细介绍三种重排') sw(0.5);sp(afi(t1));sw(1.5);sp(at(t1,t2));sp(adb(v1),adb(v2),adb(v3),adb(v4));sp(afo(t1));sw(2);sp(atm(v1,f1),afo(v2,v3,v4));sw(3);sp(atm(f1,v1),afi(v2,v3,v4)) sp(atm(v2,f2),afo(v1,v3,v4));sw(2);sp(atm(f2,v2),afi(v1,v3,v4));sp(atm(v3,f3),afo(v2,v1,v4));sw(3);sp(atm(f3,v3),afi(v2,v1,v4));sp(atm(v4,f4),afo(v2,v3,v1));sw(2);sp(atm(f4,v4),afi(v2,v3,v1)); sp(afi(t3));sw(1.5);sp(afo(t3));sp(atm(v1,f1),afo(v2,v3,v4));sp(afo(f1[4:]));sw(1.5);sp(afo(f1[0],f1[2:4]),f1[1].animate.to_corner(UL));sw(0.5) def playscene4(): tf = xtf2(1,'Wagner-Meerwein 重排').to_corner(UL) t1=xn('碳正离子型的1,2-重排统称为 Wagner-Meerwein 重排');t2=xn('这类重排常常通过负氢或烃基迁移到临近的碳正离子上来实现');t3=xn('例如:');t4=xn('如何判断重排为负氢迁移还是烃基迁移呢?') t5=xn('重排之所以发生,是因为可以形成更加稳定的结构');t6=xn('例如,此时负氢迁移可以形成三级碳正离子,结构更加稳定');t7=xn('如果为烃基迁移,则无法降低体系能量') n1 = xnf('带着成对电子迁移');xcss(n1[2:6],BLUE);n2=n1.copy();n3=xnf('二级碳正离子').next_to(t1,2*UP).shift(2.5*LEFT);n4=xnf('三级碳正离子').next_to(t1,2*UP).shift(2.5*RIGHT);xcss(n3,RED);xcss(n4,RED);n5=n3.copy();n6=n3.copy().move_to(n4) u1 = xun('负氢迁移').shift(2*RIGHT) u2 = xun('烃基迁移').shift(2*RIGHT) b1=msm('b1');b3=msm('b3');bb=msm('bb');xos(1,b1);xos(2,b1,b3,bb);xcss(b3[6],BLUE);b4=msm('b4');b5=msm('b5');xos(1,b4);xos(2,b4,b5);xcss(b5[13:17],BLUE);xm(b4,0,b3,3);xm(b5,0,b4,0) ba=msm('ba').scale(0.14).match_y(n3);co=msm('cross').scale(1.5);xcss(co,GOLD) xcoi(b1,b3,b4,b5,bb) sa(tf);sw(0.5);sp(afi(t1));sw(2);sp(at(t1,t2));sw(3);sp(at(t1,t3)) sp(afi(b1,u1)) sp(gs(b1[16:18]));sp(gc(b1[16:18],BLUE));b1.save_state();n1.next_to(b1[16],2*RIGHT);sp(afi(n1));sw() sp(xt2(b1,b3,['16.18',6,11,12,5,5,6,7,7,8]),agf(b3[17]),ast(b1[18]));refresh(b3,n1,tf,t1,u1);sw();sp(afo(b3,shift=2*DOWN),afo(n1,shift=DOWN),afo(u1,shift=DOWN),afi(b4,shift=2*DOWN),afi(u2,shift=DOWN)) sp(gs(b4[13:17]));sp(gc(b4[13:17],BLUE));n2.next_to(b4[13],4*RIGHT);sp(afi(n2));sw() sp(xt2(b4,b5,[16,16,13,13,14,14,15,15,6,5,7,6]),agf(b5[17]),ast(b4[17]));refresh(b5,n2,tf,t1,u2);sw(2);sp(afo(b5,n2,u2),at(t1,t4));sw(2.5);sp(at(t1,t5));sw(2);b1.restore(); sp(afi(b1),at(t1,t6));sw(2);sp(afo(t1));sp(gs(b1[6],b1[18]));sp(gc(b1[6],RED,b1[18],RED));sp(afi(n3,shift=UP));xcss(b3[3],RED);xcss(b3[17],RED);sp(xt2(b1,b3,['16.18',6,11,12,5,5]),agf(b3[17]),ast(b1[18])) sp(gc(b1[6],WHITE,b1[3],RED));sp(gs(b1[3]));sp(agf(ba));sp(afi(n4,shift=UP));sw(1.5);sp(afo(n3,shift=DOWN),afo(n4,shift=DOWN),afo(ba,shift=DOWN));sp(ar(b1),ast(b3[17]));sp(afi(t7));sw(2);sp(afo(t7)) xcss(bb[19],RED);xcss(bb[3],RED);xcss(bb[15:19],BLUE);sp(gs(b1[16:18],b1[12:16],b1[6],b1[18]));sp(gc(b1[16:18],WHITE,b1[12:16],BLUE,b1[6],RED,b1[18],RED));sw();sp(afi(n5,shift=UP));sp(xt2(b1,bb,[15,18,12,15,13,16,14,17,5,13,7,6,11,10,6,5]),ast(b1[18]),agf(bb[19]),agf(bb[14])) sp(gc(b1[6],WHITE,b1[3],RED));sp(gs(b1[3]));refresh(tf,bb,n5);sp(agf(ba));sp(afi(n6,shift=UP));sw();sp(aw(co));sw(1.5);sp(afo(bb,n5,ba,n6),auw(co));sw(0.5) def playscene5(): tf = xtf2(1,'Wagner-Meerwein 重排').to_corner(UL) t1=xn('所以') t1=xn('类似地,若重排时有多种选择');t2=xn('更能稳定碳正离子的基团优先重排');t3=xn('例如,此时苯基优先于甲基重排') c1=msm("c1");c2=msm("c2");c3=msm("c3");xos(1,c1);xos(2,c1,c3);xms(c2,3,c1,3);xcoi(c1,c3);c2[3] n1=xnf('正电荷离域分布到芳环上,使碳正离子更加稳定').to_edge(DOWN) sa(tf);sw(0.5);sp(afi(t1));sw(1.75);sp(at(t1,t2));sw(2);sp(afi(c1));sp(at(t1,t3));sw(2);sp(afo(t1)) sp(xt2(c1,c2,[25,18,16,22,24,17,22,20,21,16,19,21,18,15,[17,23,20],23,15,25]),agf(c2[19]));refresh(tf,c2);sp(afi(n1));sw(2);sp(afo(n1)) sp(xt2(c2,c3,[25,25,19,24,22,15,17,23,20,21,16,20,21,18,15,17,23,[16,19,22]]),ast(c2[18]));refresh(tf,c3);sw();sp(afo(c3))View Code
scene6~10
def playscene6(): tf = xtf2(1,'Wagner-Meerwein 重排').to_corner(UL) t1=xn('Wagner-Meerwein 重排是碳正离子型的1,2-重排');t2=xn('存在碳正离子时才能发生重排');t3=xn('以下几种途径可以生成碳正离子');t4=xn('①由烯烃生成碳正离子');t5=xn('烯烃的质子化生成碳正离子,反应遵循马氏规则') n1=xnf('R为烃基或氢').shift(2.5*UP);n2=xnf('质子与π电子结合').to_edge(DOWN).shift(1.3*UP);xcss(n2[3:6],BLUE) d1=msm("d1");d2=msm("d2");d3=msm("d3");d4=msm("d4");d5=msm("d5");d6=msm("d6");xos(1,1,d1);xos(1,1.5,d3);xos(2,1,d1,d2);xos(2,1,d3,d5,d6);xcoi(d1,d2,d3,d5,d6);xs(d4,0,d3,7);d4.shift(2.5*UP) sa(tf);sw(1);sp(afi(t1));sw(2);sp(afi(d1));sp(afi(n1,shift=UP));sw();sp(xt2(d1,d2,[17,17,10,16,9,15]));refresh(n1,d2,tf,t1);sw();sp(at(t1,t2));sw(1.75);sp(at(t1,t3),afo(d2,n1));sw(1.75);sp(at(t1,t4));sw(1.75) sp(afi(d3,d4));sp(at(t1,t5));sw(2);sp(afo(t1));sp(d4.animate.shift(xgd(d4[0],d5[7])));sp(afi(n2,shift=UP));sw();sp(xt2(d3,d5,[0,8,1,0]),xt2(d4,d5,[0,7]),agf(d5[9]),ast(d4[1]));refresh(tf,d5,n2);sw();sp(xt2(d5,d6,[['7.9',3],3]));sw();sp(afo(n2,d5));sw(0.5) def playscene7(): tf = xtf2(1,'Wagner-Meerwein 重排').to_corner(UL) t1=xn('②由卤代烃生成碳正离子');t2=xn('常用Lewis酸做催化剂,来加速反应的进行(如氯化铝等)');t3=xn('③由醇生成碳正离子') n1=xnf('醇羟基质子化后容易离去').to_edge(DOWN).shift(1.3*UP); d7=msm('d7').scale(0.6);d8=msm('d8');d9=msm('d9');xms(d8,0,d7,0);xms(d9,0,d7,1);d10=msm('d10');d11=msm('d11').shift(2.5*UP);d12=msm('d12');d13=msm('d13');d14=msm('d14');xos(1,2,d10);xos(2,1,d10,d12,d13);xcoi(d10,d12,d13);xs(d11,0,d10,2);xms(d14,0,d10,2) sa(tf);sw(0.5);sp(afi(t1));sw(1.75);sp(afi(d7));sw();sp(at(d7[0],d8[0]),at(d7[1],d9[0]),at(d7[2],mvg(d8[1],d9[1])));sw();sp(at(t1,t2));sw(2.5);sp(afo(t1,d7));sw(0.5) sp(afi(t3));sw(1.75);sp(afi(d10,d11),afo(t3));sp(xt2(d11,d12,[0,3,1,5]));refresh(d12,tf);sw();sp(afi(n1,shift=UP));sw(1.75);sp(afo(n1));sp(xt([d12,d13,d14],[0,1,[0,0]],[0,2,[2,0,1,2,3,1]]));sw();refresh(d13,d14,tf);sp(afo(d13,d14));sw(0.5) def playscene8(): tf = xtf2(1,'Wagner-Meerwein 重排').to_corner(UL) t1=xn('④由脂肪族伯胺生成碳正离子');t2=xn('一级胺先重氮化,后发生分解反应') d15=msm('d15');d16=msm('d16').scale(0.7);d17=msm('d17');d18=msm('d18');d19=msm('d19');xos(1,2,d15);xos(2,1,d15,d17,d18);xms(d19,0,d17,6);xcoi(d15,d16,d17,d18,d19);d16.next_to(d15,DOWN) sa(tf);sw(0.5);sp(afi(t1));sw(1.75);sp(afi(d15));sw();sp(at(t1,t2));sw(1.5);sp(afi(d16,shift=UP));sw();sp(agf(d17[8]),GrowFromEdge(d17[6:8],LEFT),ast(d15[5:7]));sp(afo(d16,t1));refresh(tf,d17);sw() sp(at(d17[8],d18[5]),xt2(d17,d19,[6,0,4,1]),ast(d17[7]));sw();refresh(tf,d18,d19);sp(afo(d18,d19));sw(0.5) def playscene9(): tf = xtf2(1,'Wagner-Meerwein 重排').to_corner(UL) f = xtfl('由碳至碳的重排反应','Wagner-Meerwein 重排','Pinacol 重排','Demyanov和Tiffen-Demyanov 重排') t1=xn('邻二醇在醇催化作用下可以重排成酮或醛');t2=xn('这个过程称为Pinacol 重排') n1=xnf('醇羟基质子化后脱去').to_edge(DOWN);n2=xnf('这里发生重排的原因是氧的孤对电子可以稳定相邻原子的正电荷').to_edge(DOWN);xcss(n2[12:16],BLUE);xcss(n2[25:],RED) n3=xnf('此时共振生成更稳定的结构').to_edge(DOWN) e0=msm('e0').scale(1.5);e1=msm("e1");e2=msm("e2");e3=msm("e3");e4=msm("e4");e5=msm("e5");e6=msm("e6");e7=msm("e7");e8=msm("e8");e9=msm("e9");xos(1,1.3,e1);xos(2,1,e1,e3,e4,e6,e7,e9);xcoi(e1,e3,e4,e6,e7,e9);xcss(e7[12],BLUE) xs(e2,0,e1,16);e2.move_to(xgd(e2[0],e1[15])).shift(1.3*DOWN);xs(e5,0,e1,16);e5.next_to(e1[16],3*RIGHT);xs(e8,0,e1,16);e8.next_to(e7[9],3*LEFT);e0.save_state() sa(tf);sw(0.5);sp(at(tf,f[1]));sp(afi(f[0],f[2:]));sw();sp(f[2].animate.to_corner(UL),afo(f[0],tf,f[3]));sw();sp(afi(e0));sw();sp(afi(t1));sw(2);sp(at(t1,t2));sw(1.5);sp(afo(t1));sp(at(e0[0:21],e1),afo(e0[21:]));refresh(f[2],e1) sp(afi(e2));sw(0.5);sp(xt2(e2,e3,[0,17,1,22]));refresh(e3,f[2]);sw(0.5);sp(afi(n1,shift=UP));sw(1.5);sp(xt2(e3,e5,[16,0,17,1,15,2]),ast(e3[22]),ast(e3[18]),agf(e4[18]));sw();refresh(e4,e5,n1,f[2]);sp(afo(n1,e5)); sw();sp(ast(e4[18]),xt2(e4,e6,[14,18,12,16,13,17]),agf(e6[15]));sw(0.5);sp(agf(e6[19]));refresh(e6,f[2]);sw();sp(afi(n2,shift=UP));sw();sp(gs(e6[15],e6[19]));sp(gc(e6[15],RED,e6[19],BLUE)) sw(2.5);sp(afo(n2,shift=UP),afi(n3,shift=UP));sw(1.5);sp(xt2(e6,e7,[19,12,11,11]),agf(e7[19]),ast(e6[15]));sw(0.5);sp(afo(n3));refresh(f[2],e7);sp(gc(e7,WHITE));sp(xt2(e7,e8,[10,0,19,1]));sw(0.5);refresh(f[2],e8,e9) e0.restore();sp(afo(e8));sp(at(e9,e0[26:]),afi(e0[0:26]));sw();refresh(e0,f[2]);sp(afo(e0));sw(0.5) def playscene10(): tf = xtf2(1,'Pinacol 重排').to_corner(UL) t1=xn('如果一个不对称的邻二醇发生重排时,哪个羟基会脱去呢?');t2=xn('这由脱去羟基后的碳正离子稳定性决定');t3=xn('故脱去上方的羟基') n1=xnf('三级碳正离子').scale(1.3).to_edge(DOWN);n2=xnf('一级碳正离子').scale(1.3).to_edge(DOWN);xcss(n1,RED);xcss(n2,RED);n3=xnf('稳定性 三级碳正离子>一级碳正离子').scale(1.3).to_edge(DOWN);xcss(n3[3:],RED) f1=msm('f1').scale(1.5);f2=msm('f2');f3=msm('f3');f20=msm('f20');f30=msm('f30');f0=msm('f0');f00=msm('f00');xos(2,1,f1,f2,f3,f20,f30);xcoi(f1,f2,f3,f20,f30);xs(f0,0,f1,6);f0.shift(3*UP);xs(f00,0,f1,6);f00.shift(3*UP) f1.save_state();f0.save_state();f00.save_state(); sa(tf);sw(0.5);sp(afi(f1));sp(afi(t1));sw(1.75);sp(ai(f1[5:7],color=BLUE),ai(f1[11:13],color=BLUE));sw();sp(at(t1,t2));sw(1.75);sp(afo(t1));sp(afi(f0)) sp(xt2(f0,f20,[0,7,1,15]));sw();refresh(tf,f20);sp(xt2(f20,f00,[6,0,7,1,5,2]),ast(f20[15]),agf(f2[11]),xt2(f20,f2,[14,10,9,5,10,6,11,7,12,8,13,9]),ast(f20[8]));refresh(tf,f2,f00);sw(0.5);sp(afi(n1,shift=UP));sw(1.5);sp(afo(n1,f00)) f1.restore();sp(afo(f2,shift=DOWN),afi(f1,shift=DOWN));f0.restore();sw();sp(afi(f0));sp(xt2(f0,f30,[0,13,1,15]));sw();refresh(tf,f30);sw();sp(xt2(f30,f00,[11,2,12,0,13,1]),xt2(f30,f3,[8,8]),agf(f3[12]),ast(f30[15]));sw(0.5);sp(afi(n2,shift=UP)) sw(1.5);f1.restore();refresh(tf,f00,f3,n2);sp(afo(f00),afo(n2,shift=UP),afi(n3,shift=UP),afo(f3,shift=DOWN),afi(f1,shift=DOWN));sw(1.75);sp(afo(n3));sp(afi(t3));sw();sp(ai(f1[5:7],color=BLUE));sw();sp(afo(f1,t3));sw(0.5)View Code
scene11~15
def playscene11(): tf=xtf2(1,'Pinacol 重排').to_corner(UL) f = xtfl('由碳至碳的重排反应','Wagner-Meerwein 重排','Pinacol 重排','Demyanov和Tiffen-Demyanov 重排') t1=xn('此外,和 W-M 重排类似,更能稳定碳正离子的基团优先重排') t2=xn('重排优先顺序为:苯基>烷基') ff1=msm('ff1');ff2=msm('ff2');xos(1,1.2,ff1);ff1.shift(0.5*UP);xos(2,1,ff1,ff2);xcoi(ff1,ff2) sa(tf);sw(0.5);sp(afi(ff1));sp(afi(t1));sw(2);sp(at(t1,t2));sw(1.75);sp(afo(t1)) sp(xt2(ff1,ff2,[17,14,19,17,13,12]),ast(ff1[12]),ast(ff1[14:17]),agf(ff2[13]));sw();refresh(ff2,tf);sp(afo(ff2));sw() sp(tf.animate.move_to(f[2]),afi(f[0:2],f[3]),);sw();sp(f[3].animate.to_corner(UL),afo(f[0:2],tf));sw(0.5) def playscene12(): tf=xtf2(1,'Demyanov和Tiffen-Demyanov 重排').to_corner(UL) t1=xn('脂肪族伯胺重氮化反应中发生的扩环或缩环反应称为 Demyanov 重排');t2=xn('若脂肪环上连有氨甲基,重排生成扩环的产物');t3=xn('若脂肪环上直接连有氨基,重排生成缩环的产物') g0=msm('g0').scale(0.8);h0=msm('h0').scale(0.8).shift(0.5*RIGHT);xms(g0,8,h0,5);g0.shift(1.3*UP);h0.shift(1.3*DOWN) g1=msm("g1").scale(1.3);g2=msm("g2");g3=msm("g3");g4=msm("g4").scale(1.3);g5=msm("g5");g6=msm("g6");f0=msm('f0');f00=msm('f00');xos(2,1,g1,g2,g3);xos(2,1,g4,g5,g6);xcoi(g1,g2,g3,g4,g5,g6);xs(f0,0,g5,6);xs(f00,0,g5,6);f0.to_edge(DOWN);f00.to_edge(DOWN) gn=msm('gn').scale(0.7).shift(1.5*UP);N=msm('d19');xs(N,0,g2,7);N.to_edge(DOWN);xc1(g3);g0.save_state() n1=xnf('此处形成碳正离子的方法在 W-M 重排中提到过');n2=xnf('重氮化后分解得到碳正离子');n3=xnf('扩环的动力之一是可以降低环张力(小环的环张力较大)');n4=xnf('随后碳正离子与水结合生成氧鎓盐,再失去质子变为醇') sa(tf);sw(0.5);sp(afi(g0,h0));sw(0.5);sp(afi(t1));sw(3);sp(art(t1,t2));sw(1.5);sp(ai(t2[15:17],color=BLUE),ai(g0[0:4],color=BLUE),ai(g0[14:19],color=BLUE));sw();sp(art(t2,t3)) sw(1.5);sp(ai(t3[16:18],color=BLUE),ai(h0[0:4],color=BLUE,scale_factor=1.5),ai(h0[11:14],color=BLUE));sw();sp(afo(t3,h0,g0[11:]),at(g0[0:11],g1));sw();sp(afi(n1,shift=UP));sw(2);sp(afo(n1,shift=UP),afi(n2,shift=UP));sw(1.75);sp(afo(n2),afi(gn,shift=DOWN)) refresh(tf,gn,g1);sp(ast(g1[8:10]),agf(g2[13]),GrowFromEdge(g2[9:13],LEFT));sp(afo(gn));sw(0.5);refresh(tf,g2);sp(xt2(g2,N,[7,0,9,1]),ast(g2[13]),ast(g2[10:13]),agf(g3[8]));refresh(tf,g3,N);sp(afo(N));sw(0.5) xc2(g3);sw();sp(xt([g3,g4],[0,1,[1,1,2,2,7,3,3,4,0,0,8,5]]),run_time=2);refresh(tf,g4);sw();xc3(g4);sp(afi(n3,shift=UP));sw(2);sp(afo(n3,shift=UP),afi(n4,shift=UP));sw(2.5);sp(afo(n4));refresh(tf,g4);sp(afi(f00));sw(0.5) sp(xt2(f00,g5,[0,6,1,7,2,5]),GrowFromEdge(g5[8],LEFT),agf(g5[9]),ast(g4[5]));sw();refresh(g5,tf);sp(xt2(g5,f0,[7,0,9,1]));sw();refresh(g6,f0,tf);sp(afo(f0));g0.restore(); wid=g0[14:].get_center()-g6.get_center();sca=g0[14:].width/g6.width;sp(g6.animate.shift(wid).scale(sca),afi(g0[0:14]),afi(h0));sw(0.5) def playscene13(): tf=xtf2(1,'Demyanov和Tiffen-Demyanov 重排').to_corner(UL) n1=xnf('反应过程与前述反应类似');n2=xnf('此处重排缩环受环张力的影响不大');n3=xnf('主要原因是环丙基甲基碳正离子很稳定');n4=xnf('首先,在环丙烷中,碳碳键为了维持正常的键角会发生弯曲');n5=xnf('称之为香蕉键') n6=xnf('碳正离子空的p轨道可以俯向环的左边或右边,形成σ-p超共轭体系');n7=xnf('这样正电荷得到分散,体系变得稳定') g0=msm('g0').scale(0.8);h0=msm('h0').scale(0.8).shift(0.5*RIGHT);xms(g0,8,h0,5);g0.shift(1.3*UP);h0.shift(1.3*DOWN) h1=msm("h1").scale(1.3);h2=msm("h2");h3=msm("h3");h4=msm("h4");h5=msm("h5");h6=msm("h6");xos(2,1,h1,h2,h3);xos(2,1,h4,h5,h6);xcoi(h1,h2,h3,h4,h5,h6); gn=msm('gn').scale(0.7).shift(1.5*UP);N=msm('d19');xs(N,0,h2,4);N.to_edge(DOWN);xc1(h3); f0=msm('f0');f00=msm('f00');xs(f0,0,h4,4);xs(f00,0,h4,4);f0.to_edge(DOWN);f00.to_edge(DOWN) hr0=msm('hr0');hr1=msm('hr1');hr10=msm('hr10');hr2=msm('hr2');hr3=msm('hr3');xms(hr0,1,h4,0);xms(hr1,8,hr0,8);xms(hr10,7,hr1,1);h0.save_state() xoc(hr0[8:10]);xoc(hr1[8:10]);xoc(hr2[4:6]);xoc(hr2[10:12]);xoc(hr3[4:6]);xoc(hr3[10:12]);xoc(hr10[4:6]) hrr1=msm('hrr1').scale(2);hrr2=msm('hrr2').scale(2);hrr3=msm('hrr3').scale(2.2);xoc(hrr3[0:6]);hrr3.shift(0.55*LEFT) sa(tf,g0,h0);sw(0.5);sp(at(h0[0:8],h1),afo(h0[8:],g0));sw(0.5);sp(afi(n1,shift=UP));sw(1.75);sp(afo(n1));refresh(tf,h1);sp(afi(gn,shift=DOWN));sw(0.5);sp(ast(h1[5:7]),GrowFromEdge(h2[6:10],LEFT),agf(h2[10]));sw();sp(afo(gn));refresh(tf,h2) sp(xt2(h2,N,[4,0,6,1]),ast(h2[10]),ast(h2[7:10]),ast(h2[5]),agf(h3[4]));sw();refresh(tf,h3,N);sp(afo(N));sw(0.5);xc2(h3);sp(xt([h3,h4],[0,1,[0,2,1,0,2,1,3,6,4,7]]),run_time=2);refresh(tf,h4);xc3(h4);h4.save_state();sw();sp(afi(n2,shift=UP));sw(2);sp(afi(n3,shift=UP),afo(n2,shift=UP));sw(2) sp(afi(n4,shift=UP),afo(n3,shift=UP));sw(2.5);sp(xt2(h4,hrr1,[0,0,1,1,2,2]),afo(h4[3:]));sw(0.5);refresh(tf,hrr1,n4);sp(xt2(hrr1,hrr2,[0,2,1,1,2,0]));sw();refresh(tf,hrr2,n4);sp(xt2(hrr2,hrr3,[0,8,1,6,2,7]));sp(agf(hrr3[0]),agf(hrr3[1]),agf(hrr3[2]),agf(hrr3[3]),agf(hrr3[4]),agf(hrr3[5]));sp(afi(n5,shift=UP),afo(n4,shift=UP)) h4.restore();sw(1.5);refresh(tf,hrr3,n5);sp(ast(hrr3[0]),ast(hrr3[1]),ast(hrr3[2]),ast(hrr3[3]),ast(hrr3[4]),ast(hrr3[5]),afo(n5));sp(xt2(hrr3,h4,[7,0,6,1,8,2]),afi(h4[3:]));sw();refresh(tf,h4);sp(ast(h4[3]),agf(hr0[5]),agf(hr0[7]),xt2(h4,hr0,[0,1,2,0,1,2,6,3,7,'8.11',4,4,5,6]));sw();refresh(tf,hr0) sp(xt2(hr0,hr1,[0,0,1,1,2,2]));sw();refresh(hr1,tf);sp(xt2(hr1,hr10,[3,8,8,4,9,5,10,6,5,1,7,3,4,0,6,2]));refresh(tf,hr10);sp(hr10.animate.move_to(ORIGIN).scale(1.2));xms(hr2,8,hr10,7);xms(hr3,7,hr10,7);sp(afi(n6,shift=UP));sw(2.75);sp(afi(n7,shift=UP),afo(n6,shift=UP));sw(2);sp(afo(n7)) sp(xt2(hr10,hr2,[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,8,8,9,9,'10.12',10,7]));sw();refresh(tf,hr2);sp(xt2(hr2,hr3,[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,'10.12',8,7,9,8,'10.12',9]));h4.restore();refresh(tf,hr3);sw();sp(afo(hr3,shift=DOWN),afi(h4,shift=DOWN));sp(afi(f00)) sp(xt2(f00,h5,[0,7,1,8,2,6]),ast(h4[7]),agf(h5[10]));sw();refresh(h5,tf);sp(xt2(h5,f0,[8,0,10,1]));sw(0.5);refresh(tf,f0,h6);sp(afo(f0));h0.restore();sp(xt3(h6,h0[11:]),afi(h0[0:11],g0));sw(0.5) def playscene14(): tf=xtf2(1,'Demyanov和Tiffen-Demyanov 重排').to_corner(UL) g0=msm('g0').scale(0.8);h0=msm('h0').scale(0.8).shift(0.5*RIGHT);xms(g0,8,h0,5);g0.shift(1.3*UP);h0.shift(1.3*DOWN) t1=xn('此反应的小环扩环反应产率较高,常用来制备五、六、七元环');t2=xn('后来M. Tiffeneau 改进了 Demyanov 反应');t3=xn('脂环族的β-氨基醇,可以在相同的反应条件下扩环,生成环酮');t4=xn('称为 Tiffeneau-Demyanov 反应');t5=xn('此反应可以制备四到八元环化合物,且产率比Demyanov 反应高') i1=msm('i1').scale(2);i2=msm('i2').scale(2);xcoi(i1,i2);xcss(i1[4],MAROON);xcss(i2[3],MAROON);xc1(i1); f = xtfl('由碳至碳的重排反应','Wagner-Meerwein 重排','Pinacol 重排','Demyanov和Tiffen-Demyanov 重排') sa(tf,g0,h0);sw(0.5);sp(afi(t1));sw(2.5);sp(afo(g0,h0),at(t1,t2));sw(1.75);sp(afi(i1),at(t1,t3));sw(2.5);xc2(i1);sw(0.5);sp(xt([i1,i2],[0,1,[0,7,1,0,2,1,3,2,4,3,5,5,6,6,7,8,16,4,9,9]]),run_time=2);sw(0.5);refresh(t1,tf,i2);xc3(i2);sp(at(t1,t4));sw(1.5);sp(at(t1,t5));sw(2.5);refresh(t1,tf,i2) sp(afo(i2,t1));sw();sp(tf.animate.move_to(f[-1]),afi(f[0:3]));sw();refresh(f);sp(afo(f[0][1],f[1][1],f[2][1],f[3][1]));sw(); f[0][0].generate_target();f[1][0].generate_target();f[2][0].generate_target();f[3][0].generate_target(); f[0][0].target.move_to([0,0.6,0]).rotate(-90*DEGREES);f[1][0].target.move_to([0,0.6,0]).rotate(-90*DEGREES).rotate(90*DEGREES,about_point=ORIGIN); f[2][0].target.move_to([0,0.6,0]).rotate(-90*DEGREES).rotate(2*90*DEGREES,about_point=ORIGIN);f[3][0].target.move_to([0,0.6,0]).rotate(-90*DEGREES).rotate(3*90*DEGREES,about_point=ORIGIN); sp(xal(0.3,MoveToTarget(f[0][0]),MoveToTarget(f[1][0]),MoveToTarget(f[2][0]),MoveToTarget(f[3][0])));sw();vg=mvg(f[0][0],f[1][0],f[2][0],f[3][0]);sp(adbr(vg));sw() def playscene15(): title = mt('本期视频BGM及推荐者',font='YouYuan').scale(0.8).to_edge(UP) m1 = ImageMobject(r'C:\Users\86158\Music\m1.png').scale(2);n1=xn('恶作剧ezj').set_color(color=['#C9A296','#F2E3D1']).scale(1.1).next_to(m1);v1=Group(m1,n1);xpp(v1,'ur') m2 = ImageMobject(r'C:\Users\86158\Music\m2.png').scale(2);n2=xn('空白对照实验组').set_color(color=['#708090','#BEBEBE']).scale(1.1).next_to(m2);v2=Group(m2,n2);xpp(v2,'dr') t1 = mt('The rain',font='STFangsong').scale(0.6).scale(1.3);xpp(t1,'ul') t2 = mt('A Little Story',font='STFangsong').scale(0.6).scale(1.3);xpp(t2,'dl') sw(0.5);sp(adb(title));sp(xal(0.3,agf(m1),agf(m2)));sp(xal(0.3,agf(n1),agf(n2)));sp(afi(t1,t2));sw(2);sp(afo(title,v1,v2,t1,t2));sw(0.5)View Code
icon
def icon(): iii=msm('iii').scale(3);iii[0].set_color(color = ["#FF66FF", "#FFBBFF"]);iii[1:51].set_color_by_gradient("#FF66FF","#FFBBFF");iii[51:].set_color_by_gradient("#FF66FF","#FFBBFF");sa(iii)View Code
标签:ions,args,afi,shift,sp,sw,Rearrangement,def,carbopositive 来源: https://www.cnblogs.com/daxiangcai/p/16607107.html