Best Python code snippet using toolium_python
fermatscenes.py
Source:fermatscenes.py
...33 self.wait(3)3435 def shifter(x,y,z):36 self.play(37 ApplyMethod(x.move_to,y.get_center()),38 ApplyMethod(y.move_to,z.get_center()),39 Rotating(z,radians=PI,about_point=y.get_center()),40 rate_func=smooth,run_time=1.641 )4243 shifter(r_dot,b_dot,b2_dot)44 45 self.wait(2)4647 shifter(b2_dot,r_dot,b_dot)4849 self.wait(2)5051 shifter(b_dot,b2_dot,r_dot)5253 self.wait(2)5455 self.play(ApplyMethod(dots.shift,UP*1.5))5657 #####58 #New set of dots5960 _r_dot=Dot()61 _b_dot=Dot()62 _r2_dot=Dot()6364 scale=46566 _r_dot.set_color(RED)67 _b_dot.set_color(BLUE)68 _r2_dot.set_color(RED)6970 _r_dot.scale(scale)71 _b_dot.scale(scale)72 _r2_dot.scale(scale)7374 _r_dot.next_to(_b_dot,LEFT,1)75 _r2_dot.next_to(_b_dot,RIGHT,1)7677 _dots=VGroup(_r_dot,_b_dot,_r2_dot)7879 _dots.shift(DOWN)8081 self.play(82 ShowCreation(_r_dot),83 ShowCreation(_b_dot),84 ShowCreation(_r2_dot)85 )8687 self.wait(3)8889 shifter(_r_dot,_b_dot,_r2_dot)90 91 self.wait(2)9293 shifter(_r2_dot,_r_dot,_b_dot)9495 self.wait(2)9697 shifter(_b_dot,_r2_dot,_r_dot)9899 self.wait(2)100101 self.play(ApplyMethod(dots.shift,DOWN*0.5))102103 self.wait()104105 reds1=Dot(color=RED)106 reds2=Dot(color=RED)107 reds3=Dot(color=RED)108109 blues1=Dot(color=BLUE)110 blues2=Dot(color=BLUE)111 blues3=Dot(color=BLUE)112113 reds=VGroup(reds1,reds2,reds3)114 reds.scale(4)115 reds1.next_to(reds2,LEFT,1)116 reds3.next_to(reds2,RIGHT,1)117118 reds.move_to(dots.get_center()+UP*2)119120 blues=VGroup(blues1,blues2,blues3)121 blues.scale(4)122 blues1.next_to(blues2,LEFT,1)123 blues3.next_to(blues2,RIGHT,1)124125 blues.move_to(_dots.get_center()+DOWN*2)126127 self.play(ShowCreation(reds))128 self.wait()129 self.play(ShowCreation(blues))130131 self.wait(2)132133 self.play(FadeOut(reds),FadeOut(blues))134135 self.wait(2)136137 self.play(FadeOut(_dots))138139 self.wait()140141 sh11=Dot(color=BLUE)142 sh12=Dot(color=RED)143 sh13=Dot(color=BLUE)144145 sh11.scale(4)146 sh12.scale(4)147 sh13.scale(4)148149 sh11.next_to(sh12,LEFT,1)150 sh13.next_to(sh12,RIGHT,1)151152 sh1_g=VGroup(sh11,sh12,sh13)153154 sh1_g.move_to(ORIGIN+DOWN)155156 arr1=TextMobject("$$\\rightarrow$$")157 arr1.rotate(about_point=arr1.get_center(),angle=-PI/2)158 arr1.scale(1.9)159 c_point=VGroup(dots,sh1_g)160 arr1.move_to(c_point.get_center())161162 self.wait()163164 self.play(ShowCreation(arr1))165166 self.play(ShowCreation(sh1_g))167168 self.wait()169170 sh21=Dot(color=BLUE)171 sh22=Dot(color=BLUE)172 sh23=Dot(color=RED)173174 sh21.scale(4)175 sh22.scale(4)176 sh23.scale(4)177178 sh21.next_to(sh22,LEFT,1)179 sh23.next_to(sh22,RIGHT,1)180181 sh2_g=VGroup(sh21,sh22,sh23)182183 sh2_g.move_to(ORIGIN+DOWN*3)184185 self.wait()186187 arr2=TextMobject("$$\\rightarrow$$")188 arr2.rotate(about_point=arr2.get_center(),angle=-PI/2)189 arr2.scale(1.9)190 c_point=VGroup(sh1_g,sh2_g)191 arr2.move_to(c_point.get_center())192193 self.play(ShowCreation(arr2))194195 self.play(ShowCreation(sh2_g))196197 self.wait(4)198199 self.play(200 FadeOut(arr1),201 FadeOut(arr2),202 FadeOut(dots),203 FadeOut(sh1_g),204 FadeOut(sh2_g)205 )206 self.wait()207208209#python -m manim MITintegral\Fermat\fermatscenes.py ShiftFour -pl210class ShiftFour(MovingCameraScene):211 def setup(self):212 MovingCameraScene.setup(self)213 def construct(self):214 self.camera_frame.scale(1.3)215 a=Dot(color=RED)216 b=Dot(color=RED)217 c=Dot(color=BLUE)218 d=Dot(color=BLUE)219220 scale=3221222 a.scale(scale)223 b.scale(scale)224 c.scale(scale)225 d.scale(scale)226227 a.next_to(b,LEFT,1)228 c.next_to(b,RIGHT,1)229 d.next_to(c,RIGHT,1)230231 s_dots=VGroup(a,b,c,d)232233 s_dots.move_to(ORIGIN)234235 s_dots.shift(UP*3)236237 self.play(ShowCreation(s_dots))238239 self.wait()240241 arrows=[]242243 dots=[]244245 def shift_down(a,b,c,d):246 scale=3247 a_new=Dot(color=d.get_color())248 b_new=Dot(color=a.get_color())249 c_new=Dot(color=b.get_color())250 d_new=Dot(color=c.get_color())251252 a_new.scale(3)253 b_new.scale(3)254 c_new.scale(3)255 d_new.scale(3)256257 a_new.move_to(a.get_center()+DOWN*1.8)258 b_new.move_to(b.get_center()+DOWN*1.8)259 c_new.move_to(c.get_center()+DOWN*1.8)260 d_new.move_to(d.get_center()+DOWN*1.8)261262 arr=TextMobject("$$\\rightarrow$$")263 arr.scale(1.9)264 arr.rotate(about_point=arr.get_center(),angle=-PI/2)265 f_g=VGroup(b,c,b_new,c_new)266 arr.move_to(f_g.get_center())267268 arrows.append(arr)269270 dots.append(a_new)271 dots.append(b_new)272 dots.append(c_new)273 dots.append(d_new)274275 self.play(ShowCreation(arr))276 self.play(277 ShowCreation(a_new),278 ShowCreation(b_new),279 ShowCreation(c_new),280 ShowCreation(d_new)281 )282283284 shift_down(a,b,c,d)285286 self.wait()287288 shift_down(dots[0],dots[1],dots[2],dots[3])289290 self.wait()291292 shift_down(dots[4],dots[5],dots[6],dots[7])293294 self.wait()295296 shift_down(dots[8],dots[9],dots[10],dots[11])297298 self.wait(2)299300 self.play(301 FadeOut(dots[12]),302 FadeOut(dots[13]),303 FadeOut(dots[14]),304 FadeOut(dots[15]),305 FadeOut(arrows[3])306 )307308 self.wait(3)309310 self.play(311 FadeOut(a),312 FadeOut(b),313 FadeOut(c),314 FadeOut(d),315 FadeOut(dots[0]),316 FadeOut(dots[1]),317 FadeOut(dots[2]),318 FadeOut(dots[3]),319 FadeOut(dots[4]),320 FadeOut(dots[5]),321 FadeOut(dots[6]),322 FadeOut(dots[7]),323 FadeOut(dots[8]),324 FadeOut(dots[9]),325 FadeOut(dots[10]),326 FadeOut(dots[11]),327 FadeOut(arrows[0]),328 FadeOut(arrows[1]),329 FadeOut(arrows[2])330 )331332 self.wait(2)333334335#python -m manim MITintegral\Fermat\fermatscenes.py ShiftFour2 -pl336class ShiftFour2(MovingCameraScene):337 def setup(self):338 MovingCameraScene.setup(self)339 def construct(self):340 self.camera_frame.scale(1.3)341 a=Dot(color=RED)342 b=Dot(color=BLUE)343 c=Dot(color=RED)344 d=Dot(color=BLUE)345346 scale=3347348 a.scale(scale)349 b.scale(scale)350 c.scale(scale)351 d.scale(scale)352353 a.next_to(b,LEFT,1)354 c.next_to(b,RIGHT,1)355 d.next_to(c,RIGHT,1)356357 s_dots=VGroup(a,b,c,d)358359 s_dots.move_to(ORIGIN)360361 s_dots.shift(UP*3)362363 self.play(ShowCreation(s_dots))364365 self.wait()366367 arrows=[]368369 dots=[]370371 def shift_down(a,b,c,d):372 scale=3373 a_new=Dot(color=d.get_color())374 b_new=Dot(color=a.get_color())375 c_new=Dot(color=b.get_color())376 d_new=Dot(color=c.get_color())377378 a_new.scale(3)379 b_new.scale(3)380 c_new.scale(3)381 d_new.scale(3)382383 a_new.move_to(a.get_center()+DOWN*1.8)384 b_new.move_to(b.get_center()+DOWN*1.8)385 c_new.move_to(c.get_center()+DOWN*1.8)386 d_new.move_to(d.get_center()+DOWN*1.8)387388 arr=TextMobject("$$\\rightarrow$$")389 arr.scale(1.9)390 arr.rotate(about_point=arr.get_center(),angle=-PI/2)391 f_g=VGroup(b,c,b_new,c_new)392 arr.move_to(f_g.get_center())393394 arrows.append(arr)395396 dots.append(a_new)397 dots.append(b_new)398 dots.append(c_new)399 dots.append(d_new)400401 self.play(ShowCreation(arr))402 self.play(403 ShowCreation(a_new),404 ShowCreation(b_new),405 ShowCreation(c_new),406 ShowCreation(d_new)407 )408409410 shift_down(a,b,c,d)411412 self.wait()413414 shift_down(dots[0],dots[1],dots[2],dots[3])415416 self.wait()417418 self.wait(2)419420 self.play(421 FadeOut(dots[4]),422 FadeOut(dots[5]),423 FadeOut(dots[6]),424 FadeOut(dots[7]),425 FadeOut(arrows[1])426 )427428 self.wait(2)429430 self.play(431 FadeOut(dots[0]),432 FadeOut(dots[1]),433 FadeOut(dots[2]),434 FadeOut(dots[3]),435 FadeOut(arrows[0])436 )437 self.play(ApplyMethod(s_dots.move_to,ORIGIN))438 self.play(ApplyMethod(self.camera_frame.scale,0.5))439440 self.wait(2)441442 f_g=VGroup(a,b)443444 buff=0.2445 box1=Rectangle(height=a.get_height()+buff,width=f_g.get_width()+buff,stroke_color=BLUE)446 box1.move_to(f_g.get_center())447448 f_g2=VGroup(c,d)449450 box2=Rectangle(height=a.get_height()+buff,width=f_g.get_width()+buff,stroke_color=BLUE)451 box2.move_to(f_g2.get_center())452453 self.play(ShowCreation(box1))454 self.wait()455 self.play(ShowCreation(box2))456457 self.wait(2)458459 g1=VGroup(a,b,box1)460 g2=VGroup(c,d,box2)461462 g=VGroup(g1,g2)463464 angle=ValueTracker(0)465466 dist=np.abs(g2.get_center())467468 self.play(469 ApplyMethod(g1.move_to,g2.get_center()),470 ApplyMethod(g2.move_to,g1.get_center()),471 )472473 self.wait(2)474475476477#python -m manim MITintegral\Fermat\fermatscenes.py ShiftNine -pl478class ShiftNine(MovingCameraScene):479 def setup(self):480 MovingCameraScene.setup(self)481 def construct(self):482 self.camera_frame.scale(1.3)483 a=Dot(color=RED)484 b=Dot(color=BLUE)485 c=Dot(color=GREEN)486 d=Dot(color=RED)487 e=Dot(color=BLUE)488 f=Dot(color=GREEN)489 g=Dot(color=RED)490 h=Dot(color=BLUE)491 i=Dot(color=GREEN)492493 scale=3494495 a.scale(scale)496 b.scale(scale)497 c.scale(scale)498 d.scale(scale)499 e.scale(scale)500 f.scale(scale)501 g.scale(scale)502 h.scale(scale)503 i.scale(scale)504505 a.next_to(b,LEFT,1)506 c.next_to(b,RIGHT,1)507 d.next_to(c,RIGHT,1)508 e.next_to(d,RIGHT,1)509 f.next_to(e,RIGHT,1)510 g.next_to(f,RIGHT,1)511 h.next_to(g,RIGHT,1)512 i.next_to(h,RIGHT,1)513514 s_dots=VGroup(a,b,c,d,e,f,g,h,i)515516 s_dots.move_to(ORIGIN)517518 s_dots.shift(UP*3)519520 self.play(ShowCreation(s_dots))521522 self.wait(2)523524 buff=0.2525526 f_g=VGroup(a,b,c)527528 box1=Rectangle(width=f_g.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)529 box1.move_to(f_g.get_center())530531 box2=Rectangle(width=f_g.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)532 box2.move_to(ORIGIN+UP*3)533534 box3=Rectangle(width=f_g.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)535 box3.move_to(UP*3+RIGHT*(ORIGIN-f_g.get_center()))536537 self.play(ShowCreation(box1))538539 self.wait()540541 self.play(ShowCreation(box2))542 self.play(ShowCreation(box3))543544 self.wait(2)545546 self.play(547 FadeOut(box1),548 FadeOut(box2),549 FadeOut(box3)550 )551552 arrows=[]553554 dots=[]555556 def shift_down(a,b,c,d,e,f,g,h,i):557 scale=3558 a_new=Dot(color=i.get_color())559 b_new=Dot(color=a.get_color())560 c_new=Dot(color=b.get_color())561 d_new=Dot(color=c.get_color())562 e_new=Dot(color=d.get_color())563 f_new=Dot(color=e.get_color())564 g_new=Dot(color=f.get_color())565 h_new=Dot(color=g.get_color())566 i_new=Dot(color=h.get_color())567568 a_new.scale(3)569 b_new.scale(3)570 c_new.scale(3)571 d_new.scale(3)572 e_new.scale(3)573 f_new.scale(3)574 g_new.scale(3)575 h_new.scale(3)576 i_new.scale(3)577578 a_new.move_to(a.get_center()+DOWN*1.8)579 b_new.move_to(b.get_center()+DOWN*1.8)580 c_new.move_to(c.get_center()+DOWN*1.8)581 d_new.move_to(d.get_center()+DOWN*1.8)582 e_new.move_to(e.get_center()+DOWN*1.8)583 f_new.move_to(f.get_center()+DOWN*1.8)584 g_new.move_to(g.get_center()+DOWN*1.8)585 h_new.move_to(h.get_center()+DOWN*1.8)586 i_new.move_to(i.get_center()+DOWN*1.8)587588 arr=TextMobject("$$\\rightarrow$$")589 arr.scale(1.9)590 arr.rotate(about_point=arr.get_center(),angle=-PI/2)591 f_g=VGroup(e,e_new)592 arr.move_to(f_g.get_center())593594 arrows.append(arr)595596 dots.append(a_new)597 dots.append(b_new)598 dots.append(c_new)599 dots.append(d_new)600 dots.append(e_new)601 dots.append(f_new)602 dots.append(g_new)603 dots.append(h_new)604 dots.append(i_new)605606 self.play(ShowCreation(arr))607 self.play(608 ShowCreation(a_new),609 ShowCreation(b_new),610 ShowCreation(c_new),611 ShowCreation(d_new),612 ShowCreation(e_new),613 ShowCreation(f_new),614 ShowCreation(g_new),615 ShowCreation(h_new),616 ShowCreation(i_new),617 )618619620 shift_down(a,b,c,d,e,f,g,h,i)621622 self.wait()623624 shift_down(625 dots[0],626 dots[1],627 dots[2],628 dots[3],629 dots[4],630 dots[5],631 dots[6],632 dots[7],633 dots[8]634 )635636 self.wait()637638 shift_down(639 dots[9],640 dots[10],641 dots[11],642 dots[12],643 dots[13],644 dots[14],645 dots[15],646 dots[16],647 dots[17]648 )649650 self.wait(3)651652 self.play(653 FadeOut(dots[18]),654 FadeOut(dots[19]),655 FadeOut(dots[20]),656 FadeOut(dots[21]),657 FadeOut(dots[22]),658 FadeOut(dots[23]),659 FadeOut(dots[24]),660 FadeOut(dots[25]),661 FadeOut(dots[26]),662 FadeOut(arrows[2])663 )664665 self.wait(2)666667 self.play(ApplyMethod(self.camera_frame.scale,50),run_time=2)668669 self.wait()670671#python -m manim MITintegral\Fermat\fermatscenes.py ShiftFive -pl672class ShiftFive(MovingCameraScene):673 def setup(self):674 MovingCameraScene.setup(self)675 def construct(self):676 self.camera_frame.scale(1.3)677 a=Dot(color=RED)678 b=Dot(color=BLUE)679 c=Dot(color=BLUE)680 d=Dot(color=RED)681 e=Dot(color=BLUE)682683 scale=3684685 a.scale(scale)686 b.scale(scale)687 c.scale(scale)688 d.scale(scale)689 e.scale(scale)690691 a.next_to(b,LEFT,1)692 c.next_to(b,RIGHT,1)693 d.next_to(c,RIGHT,1)694 e.next_to(d,RIGHT,1)695696 s_dots=VGroup(a,b,c,d,e)697698 s_dots.move_to(ORIGIN)699700 s_dots.shift(UP*3)701702 self.play(ShowCreation(s_dots))703704 self.wait(2)705706 buff=0.2707708 f_g=VGroup(a,b,c)709710 box1=Rectangle(width=f_g.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)711 box1.move_to(f_g.get_center())712713 box2=Rectangle(width=f_g.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)714 box2.move_to(e.get_center())715716 self.play(ShowCreation(box1))717718 self.wait()719720 self.play(ShowCreation(box2))721722 self.wait(2)723724 self.play(725 FadeOut(box1),726 FadeOut(box2),727 )728729 f_g=VGroup(a,b)730731 box1=Rectangle(width=f_g.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)732 box1.move_to(f_g.get_center())733734 f_g=VGroup(c,d)735736 box2=Rectangle(width=f_g.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)737 box2.move_to(f_g.get_center())738739 self.play(ShowCreation(box1))740 self.play(ShowCreation(box2))741742 self.wait(2)743744 self.play(745 FadeOut(box1),746 FadeOut(box2)747 )748749 self.wait(2)750751 arrows=[]752753 dots=[]754755 def shift_down(a,b,c,d,e):756 scale=3757 a_new=Dot(color=e.get_color())758 b_new=Dot(color=a.get_color())759 c_new=Dot(color=b.get_color())760 d_new=Dot(color=c.get_color())761 e_new=Dot(color=d.get_color())762763 a_new.scale(3)764 b_new.scale(3)765 c_new.scale(3)766 d_new.scale(3)767 e_new.scale(3)768769 a_new.move_to(a.get_center()+DOWN*1.8)770 b_new.move_to(b.get_center()+DOWN*1.8)771 c_new.move_to(c.get_center()+DOWN*1.8)772 d_new.move_to(d.get_center()+DOWN*1.8)773 e_new.move_to(e.get_center()+DOWN*1.8)774775 arr=TextMobject("$$\\rightarrow$$")776 arr.scale(1.9)777 arr.rotate(about_point=arr.get_center(),angle=-PI/2)778 f_g=VGroup(c,c_new)779 arr.move_to(f_g.get_center())780781 arrows.append(arr)782783 dots.append(a_new)784 dots.append(b_new)785 dots.append(c_new)786 dots.append(d_new)787 dots.append(e_new)788789 self.play(ShowCreation(arr))790 self.play(791 ShowCreation(a_new),792 ShowCreation(b_new),793 ShowCreation(c_new),794 ShowCreation(d_new),795 ShowCreation(e_new),796 )797798799 shift_down(a,b,c,d,e)800801 self.wait()802803 shift_down(804 dots[0],805 dots[1],806 dots[2],807 dots[3],808 dots[4]809 )810811 self.wait()812813 shift_down(814 dots[5],815 dots[6],816 dots[7],817 dots[8],818 dots[9]819 )820821 self.wait()822823 shift_down(824 dots[10],825 dots[11],826 dots[12],827 dots[13],828 dots[14]829 )830831 self.wait(2)832833 self.play(ApplyMethod(self.camera_frame.scale,50),834 rate_func=smooth,run_time=2)835836 self.wait()837838#python -m manim MITintegral\Fermat\fermatscenes.py ProbExp -pl839class ProbExp(Scene):840 def construct(self):841 r1=Dot(color=RED)842 r2=Dot(color=RED)843 r3=Dot(color=RED)844 b1=Dot(color=BLUE)845 b2=Dot(color=BLUE)846 b3=Dot(color=BLUE)847848 scale=4849 r1.scale(scale)850 r2.scale(scale)851 r3.scale(scale)852 b1.scale(scale)853 b2.scale(scale)854 b3.scale(scale)855856 buff=.8857858 r1.move_to(RIGHT*3.8+UP*2)859 r2.next_to(r1,RIGHT,buff)860 r3.next_to(r1,DOWN,buff)861 b1.next_to(r2,DOWN,buff)862 b2.next_to(r3,LEFT,buff)863 b3.next_to(r1,LEFT,buff)864865 dots=VGroup(866 r1,867 r2,868 r3,869 b1,870 b2,871 b3872 )873874 self.play(ShowCreation(dots))875876 self.wait(3)877878 box_b=0.2879880 box1=Rectangle(width=r1.get_width()+box_b,height=r1.get_height()+box_b)881 box2=Rectangle(width=r1.get_width()+box_b,height=r1.get_height()+box_b)882 box3=Rectangle(width=r1.get_width()+box_b,height=r1.get_height()+box_b)883884 box1.move_to(LEFT*3.7+DOWN*0.8)885 box2.next_to(box1,RIGHT,1)886 box3.next_to(box2,RIGHT,1)887888 boxes=VGroup(box1,box2,box3)889890 self.play(ShowCreation(boxes))891892 self.wait(3)893894 #markers for dot positions895 oo=Dot()896 ot=Dot()897 oth=Dot()898 to=Dot()899 tt=Dot()900 tth=Dot()901902 oo.move_to(r2.get_center())903 ot.move_to(r1.get_center())904 oth.move_to(b3.get_center())905 to.move_to(b1.get_center())906 tt.move_to(r3.get_center())907 tth.move_to(b2.get_center())908909 #move exp takes in three dots910 def move_exp(d1,d2,d3):911 c1=d1.get_center()912 c2=d2.get_center()913 c3=d3.get_center()914915 self.play(ApplyMethod(d1.move_to,box1.get_center()))916 self.play(ApplyMethod(d2.move_to,box2.get_center()))917 self.play(ApplyMethod(d3.move_to,box3.get_center()))918 self.wait()919 self.play(920 ApplyMethod(d1.move_to,c1),921 ApplyMethod(d2.move_to,c2),922 ApplyMethod(d3.move_to,c3)923 )924925 move_exp(r1,b2,b3)926927 self.wait()928929 move_exp(r3,b1,b3)930931 self.wait()932933 move_exp(r2,r3,r1)934935 self.wait(3)936937 self.play(ApplyMethod(boxes.move_to,dots.get_center()+DOWN*2.5))938939 self.wait(3)940941 self.play(ApplyMethod(box1.set_color,YELLOW))942 self.play(ApplyMethod(box1.set_color,WHITE))943944 self.play(ApplyMethod(r1.move_to,box1.get_center()))945 self.wait(0.6)946 self.play(947 ApplyMethod(r1.move_to,ot.get_center()),948 ApplyMethod(b1.move_to,box1.get_center())949 )950 self.wait(0.6)951 self.play(ApplyMethod(b1.move_to,to.get_center()))952953 self.wait(3)954955 rop1=Dot(color=RED)956 bop1=Dot(color=BLUE)957958 rop1.move_to(LEFT*5+UP*2)959 bop1.move_to(LEFT*5+DOWN*2)960961 rop1.scale(2)962 bop1.scale(2)963964 lines=[]965966 self.play(ShowCreation(rop1),ShowCreation(bop1))967968 #branch takes in a dot, and the angle and length of the lines 969 #wished to be created970 def branchup(dot,angle,leng):971 buf=0.15972 up_line=Line(973 #from974 dot.get_center()+RIGHT*buf*np.cos(angle)+UP*buf*np.sin(angle),975 #to976 dot.get_center()+RIGHT*buf*np.cos(angle)+UP*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+UP*leng*np.sin(angle)977 )978 red=Dot(color=RED)979 red.scale(2)980 red.move_to(dot.get_center()+RIGHT*buf*np.cos(angle)+UP*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+UP*leng*np.sin(angle)+RIGHT*buf*np.cos(angle)+UP*buf*np.sin(angle))981 lines.append(up_line)982 self.play(ShowCreation(red),ShowCreation(up_line))983 return red984985 def branchdown(dot,angle,leng):986 buf=0.15987 down_line=Line(988 #from989 dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle),990 #to991 dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+DOWN*leng*np.sin(angle)992 )993 blue=Dot(color=BLUE)994 blue.scale(2)995 blue.move_to(dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+DOWN*leng*np.sin(angle)+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle))996 lines.append(down_line)997 self.play(ShowCreation(blue),ShowCreation(down_line))998 return blue9991000 self.wait(2)10011002 self.play(ApplyMethod(box2.set_color,YELLOW))1003 self.play(ApplyMethod(box2.set_color,WHITE))10041005 self.play(ApplyMethod(r1.move_to,box2.get_center()))1006 self.wait(0.6)1007 self.play(1008 ApplyMethod(r1.move_to,ot.get_center()),1009 ApplyMethod(b1.move_to,box2.get_center())1010 )1011 self.wait(0.6)1012 self.play(ApplyMethod(b1.move_to,to.get_center()))10131014 rop1_u=branchup(rop1,PI/6,1.4)1015 rop1_d=branchdown(rop1,PI/6,1.4)10161017 self.wait(2)10181019 bop1_u=branchup(bop1,PI/6,1.4)1020 bop1_d=branchdown(bop1,PI/6,1.4)10211022 self.wait(2)10231024 ####1025 #Third round10261027 self.play(ApplyMethod(box3.set_color,YELLOW))1028 self.play(ApplyMethod(box3.set_color,WHITE))10291030 self.play(ApplyMethod(r1.move_to,box3.get_center()))1031 self.wait(0.6)1032 self.play(1033 ApplyMethod(r1.move_to,ot.get_center()),1034 ApplyMethod(b1.move_to,box3.get_center())1035 )1036 self.wait(0.6)1037 self.play(ApplyMethod(b1.move_to,to.get_center()))10381039 self.wait(2)10401041 an=PI/91042 l=0.810431044 rop1_u_u=branchup(rop1_u,an,l)1045 rop1_u_d=branchdown(rop1_u,an,l)10461047 rop1_d_u=branchup(rop1_d,an,l)1048 rop1_d_d=branchdown(rop1_d,an,l)10491050 bop1_u_u=branchup(bop1_u,an,l)1051 bop1_u_d=branchdown(bop1_u,an,l)10521053 bop1_d_u=branchup(bop1_d,an,l)1054 bop1_d_d=branchdown(bop1_d,an,l)10551056 self.wait(3)10571058 #separaters10591060 group1=VGroup(rop1,bop1)1061 sep1=Rectangle(width=rop1.get_width()+box_b,height=group1.get_height()+box_b,stroke_color=BLUE)1062 sep1.move_to(group1.get_center())1063 self.play(ShowCreation(sep1))10641065 self.wait(2)10661067 two1=TextMobject("2")1068 two1.scale(1.7)1069 two1.next_to(box1,DOWN*0.5)1070 self.play(Write(two1))10711072 self.wait()10731074 group2=VGroup(rop1_u,bop1_d)1075 sep2=Rectangle(width=rop1.get_width()+box_b,height=group2.get_height()+box_b,stroke_color=BLUE)1076 sep2.move_to(group2.get_center())1077 self.play(ShowCreation(sep2))10781079 self.wait(2)10801081 two2=TextMobject("2")1082 two2.scale(1.7)1083 two2.next_to(box2,DOWN*0.5)10841085 times=TextMobject("$$\\times$$")1086 f_g=VGroup(two1,two2)1087 times.move_to(f_g.get_center())10881089 self.play(Write(times),Write(two2))10901091 self.wait()10921093 group3=VGroup(rop1_u_u,bop1_d_d)1094 sep3=Rectangle(width=rop1.get_width()+box_b,height=group3.get_height()+box_b,stroke_color=BLUE)1095 sep3.move_to(group3.get_center())1096 self.play(ShowCreation(sep3))10971098 self.wait(2)10991100 two3=TextMobject("2")1101 two3.scale(1.7)1102 two3.next_to(box3,DOWN*0.5)11031104 times2=TextMobject("$$\\times$$")1105 f_g2=VGroup(two2,two3)1106 times2.move_to(f_g2.get_center())11071108 self.play(Write(times2),Write(two3))11091110 self.wait(2)11111112 all_=VGroup(two1,two2,two3,times,times2)1113 two_cu=TextMobject("$$2^{3}$$")1114 two_cu.scale(1.7)1115 two_cu.next_to(box2,DOWN,0.6)11161117 self.play(Transform(all_,two_cu))11181119 self.wait(3)11201121 self.play(1122 FadeOut(all_),1123 FadeOut(sep1),1124 FadeOut(sep2),1125 FadeOut(sep3)1126 )11271128 self.wait()11291130 ######################1131 #Fourth box stuff11321133 dist=box3.get_center()-box2.get_center()11341135 self.play(ApplyMethod(boxes.shift,LEFT*dist))11361137 box4=Rectangle(width=r1.get_width()+box_b,height=r1.get_height()+box_b)11381139 box4.next_to(box3,RIGHT,1)11401141 self.play(ShowCreation(box4))11421143 self.wait()11441145 self.play(ApplyMethod(box4.set_color,YELLOW))1146 self.play(ApplyMethod(box4.set_color,WHITE))11471148 self.play(ApplyMethod(r1.move_to,box4.get_center()))1149 self.wait(0.6)1150 self.play(1151 ApplyMethod(r1.move_to,ot.get_center()),1152 ApplyMethod(b1.move_to,box4.get_center())1153 )1154 self.wait(0.6)1155 self.play(ApplyMethod(b1.move_to,to.get_center()))11561157 self.wait(3)11581159 an=PI/14.51160 l=0.511611162 rop1_u_u_u=branchup(rop1_u_u,an,l)1163 rop1_u_u_d=branchdown(rop1_u_u,an,l)11641165 rop1_u_d_u=branchup(rop1_u_d,an,l)1166 rop1_u_d_d=branchdown(rop1_u_d,an,l)11671168 rop1_d_u_u=branchup(rop1_d_u,an,l)1169 rop1_d_u_d=branchdown(rop1_d_u,an,l)11701171 rop1_d_d_u=branchup(rop1_d_d,an,l)1172 rop1_d_d_d=branchdown(rop1_d_d,an,l)11731174 bop1_u_u_u=branchup(bop1_u_u,an,l)1175 bop1_u_u_d=branchdown(bop1_u_u,an,l)11761177 bop1_u_d_u=branchup(bop1_u_d,an,l)1178 bop1_u_d_d=branchdown(bop1_u_d,an,l)11791180 bop1_d_u_u=branchup(bop1_d_u,an,l)1181 bop1_d_u_d=branchdown(bop1_d_u,an,l)11821183 bop1_d_d_u=branchup(bop1_d_d,an,l)1184 bop1_d_d_d=branchdown(bop1_d_d,an,l)11851186 self.wait(2)11871188 two1=TextMobject("2")1189 two1.scale(1.7)1190 two1.next_to(box2,DOWN*0.5)1191 two2=TextMobject("2")1192 two2.scale(1.7)1193 two2.next_to(box3,DOWN*0.5)11941195 times=TextMobject("$$\\times$$")1196 f_g=VGroup(two1,two2)1197 times.move_to(f_g.get_center())1198 two3=TextMobject("2")1199 two3.scale(1.7)1200 two3.next_to(box4,DOWN*0.5)12011202 times2=TextMobject("$$\\times$$")1203 f_g2=VGroup(two2,two3)1204 times2.move_to(f_g2.get_center())1205 all_=VGroup(two1,two2,two3,times,times2)12061207 two0=TextMobject("2")1208 two0.scale(1.7)1209 two0.next_to(box1,DOWN*0.5)12101211 times0=TextMobject("$$\\times$$")1212 f_g0=VGroup(two0,two1)1213 times0.move_to(f_g0.get_center())12141215 all2_=VGroup(1216 two0,1217 times0,1218 all_1219 )12201221 self.play(Write(all2_))12221223 two_f=TextMobject("$$2^{4}$$")1224 two_f.scale(1.7)1225 f_g3=VGroup(two1,two2)1226 two_f.move_to(f_g3.get_center())12271228 self.wait()12291230 self.play(Transform(all2_,two_f))12311232 self.wait(3)12331234 self.play(FadeOut(two_f),FadeOut(all2_))12351236 self.play(FadeOut(box4))12371238 self.play(ApplyMethod(boxes.shift,RIGHT*dist))12391240 self.play(1241 FadeOut(lines[0]),1242 FadeOut(lines[1]),1243 FadeOut(lines[2]),1244 FadeOut(lines[3]),1245 FadeOut(lines[4]),1246 FadeOut(lines[5]),1247 FadeOut(lines[6]),1248 FadeOut(lines[7]),1249 FadeOut(lines[8]),1250 FadeOut(lines[9]),1251 FadeOut(lines[10]),1252 FadeOut(lines[11]),1253 FadeOut(lines[12]),1254 FadeOut(lines[13]),1255 FadeOut(lines[14]),1256 FadeOut(lines[15]),1257 FadeOut(lines[16]),1258 FadeOut(lines[17]),1259 FadeOut(lines[18]),1260 FadeOut(lines[19]),1261 FadeOut(lines[20]),1262 FadeOut(lines[21]),1263 FadeOut(lines[22]),1264 FadeOut(lines[23]),1265 FadeOut(lines[24]),1266 FadeOut(lines[25]),1267 FadeOut(lines[26]),1268 FadeOut(lines[27]),1269 FadeOut(rop1_u),1270 FadeOut(rop1_d),1271 FadeOut(rop1_u_u),1272 FadeOut(rop1_u_d),1273 FadeOut(rop1_d_u),1274 FadeOut(rop1_d_d),1275 FadeOut(rop1_u_u_u),1276 FadeOut(rop1_u_d_u),1277 FadeOut(rop1_d_u_u),1278 FadeOut(rop1_d_d_u),1279 FadeOut(rop1_u_u_d),1280 FadeOut(rop1_u_d_d),1281 FadeOut(rop1_d_u_d),1282 FadeOut(rop1_d_d_d),1283 FadeOut(bop1_u),1284 FadeOut(bop1_d),1285 FadeOut(bop1_u_u),1286 FadeOut(bop1_u_d),1287 FadeOut(bop1_d_u),1288 FadeOut(bop1_d_d),1289 FadeOut(bop1_u_u_u),1290 FadeOut(bop1_u_d_u),1291 FadeOut(bop1_d_u_u),1292 FadeOut(bop1_d_d_u),1293 FadeOut(bop1_u_u_d),1294 FadeOut(bop1_u_d_d),1295 FadeOut(bop1_d_u_d),1296 FadeOut(bop1_d_d_d),1297 )12981299 self.wait(3)13001301 self.play(ApplyMethod(r1.set_color,GREEN),ApplyMethod(b1.set_color,GREEN))13021303 self.play(ApplyMethod(r2.move_to,box1.get_center())),13041305 self.play(1306 ApplyMethod(r2.move_to,oo.get_center()),1307 ApplyMethod(b2.move_to,box1.get_center())1308 )13091310 self.play(1311 ApplyMethod(b2.move_to,tth.get_center()),1312 ApplyMethod(r1.move_to,box1.get_center())1313 )1314 self.play(ApplyMethod(r1.move_to,ot.get_center()))13151316 self.wait(3)13171318 gop1=Dot(color=GREEN)1319 gop1.scale(2)1320 ops=VGroup(rop1,bop1)1321 gop1.move_to(ops.get_center())13221323 self.play(ShowCreation(gop1))13241325 self.wait(2)13261327 def branchmid(dot,angle,leng):1328 buf=0.151329 down_line=Line(1330 #from1331 dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle),1332 #to1333 dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+DOWN*leng*np.sin(angle)1334 )1335 green=Dot(color=GREEN)1336 green.scale(2)1337 green.move_to(dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+DOWN*leng*np.sin(angle)+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle))1338 lines.append(down_line)1339 self.play(ShowCreation(green),ShowCreation(down_line))1340 return green13411342 an=PI/81343 l=1.413441345 rop1_u=branchup(rop1,an,l)1346 rop1_m=branchmid(rop1,0,np.cos(an)*l)1347 rop1_d=branchdown(rop1,an,l)13481349 gop1_u=branchup(gop1,an,l)1350 gop1_m=branchmid(gop1,0,np.cos(an)*l)1351 gop1_d=branchdown(gop1,an,l)13521353 bop1_u=branchup(bop1,an,l)1354 bop1_m=branchmid(bop1,0,np.cos(an)*l)1355 bop1_d=branchdown(bop1,an,l)13561357 self.wait(3)13581359 def branchup(dot,angle,leng):1360 buf=0.151361 up_line=Line(1362 #from1363 dot.get_center()+RIGHT*buf*np.cos(angle)+UP*buf*np.sin(angle),1364 #to1365 dot.get_center()+RIGHT*buf*np.cos(angle)+UP*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+UP*leng*np.sin(angle)1366 )1367 red=Dot(color=RED)1368 red.scale(1)1369 red.move_to(dot.get_center()+RIGHT*buf*np.cos(angle)+UP*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+UP*leng*np.sin(angle)+RIGHT*buf*np.cos(angle)+UP*buf*np.sin(angle))1370 lines.append(up_line)1371 self.play(ShowCreation(red),ShowCreation(up_line))1372 return red13731374 def branchdown(dot,angle,leng):1375 buf=0.151376 down_line=Line(1377 #from1378 dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle),1379 #to1380 dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+DOWN*leng*np.sin(angle)1381 )1382 blue=Dot(color=BLUE)1383 blue.scale(1)1384 blue.move_to(dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+DOWN*leng*np.sin(angle)+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle))1385 lines.append(down_line)1386 self.play(ShowCreation(blue),ShowCreation(down_line))1387 return blue13881389 def branchmid(dot,angle,leng):1390 buf=0.151391 down_line=Line(1392 #from1393 dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle),1394 #to1395 dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+DOWN*leng*np.sin(angle)1396 )1397 green=Dot(color=GREEN)1398 green.scale(1)1399 green.move_to(dot.get_center()+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle)+RIGHT*leng*np.cos(angle)+DOWN*leng*np.sin(angle)+RIGHT*buf*np.cos(angle)+DOWN*buf*np.sin(angle))1400 lines.append(down_line)1401 self.play(ShowCreation(green),ShowCreation(down_line))1402 return green14031404 an=PI/181405 l=114061407 rop1_u_u=branchup(rop1_u,an,l)1408 rop1_u_m=branchmid(rop1_u,0,np.cos(an)*l)1409 rop1_u_d=branchdown(rop1_u,an,l)14101411 rop1_m_u=branchup(rop1_m,an,l)1412 rop1_m_m=branchmid(rop1_m,0,np.cos(an)*l)1413 rop1_m_d=branchdown(rop1_m,an,l)14141415 rop1_d_u=branchup(rop1_d,an,l)1416 rop1_d_m=branchmid(rop1_d,0,np.cos(an)*l)1417 rop1_d_d=branchdown(rop1_d,an,l)141814191420 gop1_u_u=branchup(gop1_u,an,l)1421 gop1_u_m=branchmid(gop1_u,0,np.cos(an)*l)1422 gop1_u_d=branchdown(gop1_u,an,l)14231424 gop1_m_u=branchup(gop1_m,an,l)1425 gop1_m_m=branchmid(gop1_m,0,np.cos(an)*l)1426 gop1_m_d=branchdown(gop1_m,an,l)14271428 gop1_d_u=branchup(gop1_d,an,l)1429 gop1_d_m=branchmid(gop1_d,0,np.cos(an)*l)1430 gop1_d_d=branchdown(gop1_d,an,l)143114321433 bop1_u_u=branchup(bop1_u,an,l)1434 bop1_u_m=branchmid(bop1_u,0,np.cos(an)*l)1435 bop1_u_d=branchdown(bop1_u,an,l)14361437 bop1_m_u=branchup(bop1_m,an,l)1438 bop1_m_m=branchmid(bop1_m,0,np.cos(an)*l)1439 bop1_m_d=branchdown(bop1_m,an,l)14401441 bop1_d_u=branchup(bop1_d,an,l)1442 bop1_d_m=branchmid(bop1_d,0,np.cos(an)*l)1443 bop1_d_d=branchdown(bop1_d,an,l)14441445 self.wait(3)14461447 self.play(ShowCreation(sep1))1448 self.wait()1449 th1=TextMobject("3")1450 th1.scale(1.7)1451 th1.next_to(box1,DOWN,0.2)1452 self.play(ShowCreation(th1))14531454 self.wait(2)14551456 sep2_pos=VGroup(rop1_u,bop1_d)1457 sep2.move_to(sep2_pos.get_center())1458 self.play(ShowCreation(sep2))1459 self.wait()1460 th2=TextMobject("3")1461 th2.scale(1.7)1462 th2.next_to(box2,DOWN,0.2)1463 times2=TextMobject("$$\\times$$")1464 f_g4=VGroup(th1,th2)1465 times2.move_to(f_g4.get_center())14661467 self.play(ShowCreation(th2),ShowCreation(times2))14681469 self.wait(2)14701471 sep3_pos=VGroup(rop1_u_u,bop1_d_d)1472 sep3.move_to(sep3_pos.get_center())1473 self.play(ShowCreation(sep3))1474 self.wait()1475 th3=TextMobject("3")1476 th3.scale(1.7)1477 th3.next_to(box3,DOWN,0.2)1478 times3=TextMobject("$$\\times$$")1479 f_g5=VGroup(th2,th3)1480 times3.move_to(f_g5.get_center())1481 self.play(ShowCreation(th3),ShowCreation(times3))14821483 self.wait(3)14841485 th_cu=TextMobject("$$3^{3}$$")1486 th_cu.scale(1.7)14871488 th_cu.next_to(box2,DOWN,0.6)14891490 threes_plus=VGroup(th1,th2,th3,times3,times2)14911492 self.play(Transform(threes_plus,th_cu))14931494 self.wait(4)149514961497#python -m manim MITintegral\Fermat\fermatscenes.py IntroClips -pl1498class IntroClips(Scene):1499 def construct(self):1500 fermat=TextMobject("Fermat's")1501 fermat.scale(1.6)1502 little=TextMobject("little")1503 little.scale(1.2)1504 little.set_color(BLUE)1505 theorem=TextMobject("theorem")1506 theorem.scale(1.6)1507 fermat.next_to(little,LEFT,0.5)1508 theorem.next_to(little,RIGHT,0.5)15091510 title=VGroup(fermat,little,theorem)1511 title.move_to(ORIGIN)15121513 self.play(Write(title))15141515 self.wait(4)15161517 self.play(FadeOut(title))15181519 a=TextMobject("$$a$$")1520 po=TextMobject("$$p$$")1521 a.scale(2)1522 po.scale(2)15231524 pers.sep_exp(a,po)1525 po.set_color(BLUE)15261527 th1=VGroup(a,po)15281529 min_a=TextMobject("$$-a$$")1530 min_a.scale(2)1531 min_a.next_to(th1,RIGHT,0.1)1532 min_a.align_to(th1,DOWN)15331534 th=VGroup(th1,min_a)15351536 bar=Line(ORIGIN,RIGHT*(0.2+th.get_width()),stroke_width=3)15371538 bar.next_to(th,DOWN,0.13)15391540 p=TextMobject("$$p$$")1541 p.set_color(BLUE)15421543 p.scale(2)15441545 p.next_to(bar,DOWN,0.13)15461547 whole=VGroup(th,bar,p)15481549 whole.move_to(ORIGIN)15501551 po.scale(2)15521553 self.play(Write(po))1554 self.wait()1555 self.play(ApplyMethod(po.scale,0.5))15561557 self.play(Write(a))15581559 self.wait(2)15601561 self.play(Write(min_a))15621563 self.wait()15641565 self.play(ShowCreation(bar))15661567 self.play(Write(p))15681569 self.wait(3)15701571 self.play(FadeOut(whole))15721573 self.wait(2)15741575#The following scene represents how I can call on a personal method from the 1576#file: my_methods.py, located in manimlib. NOTE: since the method I am using1577#uses a "self.play" in the function, it must be passed self (and the method must1578#be written to accept self). 15791580#python -m manim MITintegral\Fermat\fermatscenes.py Calling_Method -pl1581class Calling_Method(Scene):1582 def construct(self):1583 seven=TextMobject("7")1584 pers.print_col(self,seven)15851586 self.wait(2)15871588#python -m manim MITintegral\Fermat\fermatscenes.py test -pl1589class test(Scene):1590 def construct(self):15911592 th=TextMobject("$$3$$")1593 five=TextMobject("$$5$$")15941595 whole=VGroup(th,five)15961597 whole.scale(3)159815991600 pers.sep_exp(th,five)16011602 self.play(Write(th),Write(five))16031604 self.wait(2)16051606 five.set_color(BLUE)16071608 self.wait(3)16091610#python -m manim MITintegral\Fermat\fermatscenes.py ProbCont -pl1611class ProbCont(Scene):1612 def construct(self):1613 base=TextMobject("$$\#\mbox{ colors}$$")1614 exp=TextMobject("$$\#\mbox{ boxes}$$")1615 min_a=TextMobject("$$-a$$")1616 exp.set_color(BLUE)1617 base.scale(2)1618 exp.scale(2)16191620 pers.sep_exp(base,exp)16211622 state=VGroup(base,exp)16231624 self.play(Write(state))16251626 self.wait(2)16271628 a=TextMobject("$$a$$")1629 a.move_to(base.get_center())1630 a.scale(2)1631 self.play(Transform(base,a))16321633 p=TextMobject("$$p$$")1634 p.scale(2)1635 p.set_color(BLUE)16361637 pers.sep_exp(a,p)16381639 self.wait(2)16401641 self.play(Transform(exp,p))16421643 self.wait(3)16441645 f_g=VGroup(a,p)16461647 min_a.scale(2)16481649 min_a.next_to(f_g,RIGHT,0.1)16501651 min_a.align_to(f_g,DOWN)16521653 self.play(Write(min_a))16541655 self.wait(2)16561657 noth=TextMobject("")16581659 all_=VGroup(min_a,base,exp)16601661 self.play(Transform(all_,noth))16621663 self.wait()16641665#python -m manim MITintegral\Fermat\fermatscenes.py NoahIntro -pl1666class NoahIntro(MovingCameraScene):1667 def setup(self):1668 MovingCameraScene.setup(self)1669 def construct(self):1670 treble=SVGMobject("treble_svg",fill_color=BLUE,fill_opacity=0,stroke_width=3,stroke_color=YELLOW)1671 treble.scale(3)1672 noah=TextMobject("\\textit{NOAH FORBES}",fill_color=WHITE,stroke_width=4,stroke_color=BLUE,fill_opacity=1)1673 #noah.set_color(BLUE)1674 noah.shift(DOWN)16751676 music=TextMobject("MUSIC",fill_color=WHITE,stroke_width=2,stroke_color=BLUE)1677 music.scale(2)1678 notes=TextMobject("NOTES",fill_color=WHITE,stroke_width=2,stroke_color=BLUE)1679 notes.scale(2)1680 with_=TextMobject("WITH",fill_color=WHITE,stroke_width=2,stroke_color=BLUE)1681 with_.shift(UP*0.8)1682 with_.scale(1.5)16831684 music.move_to(UP*2+LEFT*3.4)1685 notes.move_to(UP*2+RIGHT*3.4)16861687 self.bring_to_back(treble)1688 self.remove(treble)16891690 self.wait(2)16911692 self.play(Write(music))1693 self.wait()1694 self.play(Write(notes))1695 self.wait()1696 self.play(Write(with_))1697 self.add_foreground_mobjects(with_)1698 self.wait()16991700 noah.scale(3.7)1701 self.wait()1702 self.play(ShowCreation(treble))1703 self.wait()1704 self.play(Write(noah))1705 self.wait(2)17061707 self.play(1708 ApplyMethod(self.camera_frame.scale,0.006)1709 )17101711 self.wait()17121713#python -m manim MITintegral\Fermat\fermatscenes.py PrimeShifts -pl1714class PrimeShifts(Scene):1715 def construct(self):1716 r1=Dot(color=RED)1717 b1=Dot(color=BLUE)1718 r2=Dot(color=RED)17191720 dots=VGroup(r1,b1,r2)17211722 dots.scale(2)17231724 r1.next_to(b1,LEFT)1725 r2.next_to(b1,RIGHT)17261727 self.play(ShowCreation(dots))17281729 self.wait()17301731#python -m manim MITintegral\Fermat\fermatscenes.py PieceTogether -pl1732class PieceTogether(MovingCameraScene):1733 def setup(self):1734 MovingCameraScene.setup(self)1735 def construct(self):17361737 arr_sc=2.517381739 self.camera_frame.scale(1.5)17401741 r_dot=Dot(color=RED)1742 b_dot=Dot(color=BLUE)1743 b2_dot=Dot(color=BLUE)17441745 scale=417461747 r_dot.scale(scale)1748 b_dot.scale(scale)1749 b2_dot.scale(scale)17501751 r_dot.next_to(b_dot,LEFT,1)1752 b2_dot.next_to(b_dot,RIGHT,1)17531754 dots=VGroup(r_dot,b_dot,b2_dot)17551756 self.play(ShowCreation(dots))17571758 self.wait(2)17591760 self.play(ApplyMethod(dots.move_to,LEFT*7.5+UP*2))17611762 r_dot2=Dot(color=RED)1763 r2_dot2=Dot(color=RED)1764 b_dot2=Dot(color=BLUE)17651766 r_dot2.scale(scale)1767 r2_dot2.scale(scale)1768 b_dot2.scale(scale)17691770 r_dot2.next_to(r2_dot2,LEFT,1)1771 b_dot2.next_to(r2_dot2,RIGHT,1)17721773 _dots=VGroup(r_dot2,r2_dot2,b_dot2)17741775 _dots.move_to(LEFT*7.5+DOWN*2)17761777 self.play(ShowCreation(_dots))17781779 self.wait(2)17801781 r_dot_u2=Dot(color=BLUE)1782 b_dot_u2=Dot(color=RED)1783 b2_dot_u2=Dot(color=BLUE)17841785 scale=417861787 r_dot_u2.scale(scale)1788 b_dot_u2.scale(scale)1789 b2_dot_u2.scale(scale)17901791 r_dot_u2.next_to(b_dot_u2,LEFT,1)1792 b2_dot_u2.next_to(b_dot_u2,RIGHT,1)17931794 dots_u2=VGroup(r_dot_u2,b_dot_u2,b2_dot_u2)17951796 dots_u2.shift(UP*2)17971798 arr_u1=TextMobject("$$\\rightarrow$$")1799 arr_u1.scale(arr_sc)1800 u_f_g=VGroup(dots,dots_u2)1801 arr_u1.move_to(u_f_g.get_center())18021803 self.play(ShowCreation(arr_u1))18041805 self.play(ShowCreation(dots_u2))18061807 self.wait()18081809 r_dot2_d2=Dot(color=BLUE)1810 r2_dot2_d2=Dot(color=RED)1811 b_dot2_d2=Dot(color=RED)18121813 r_dot2_d2.scale(scale)1814 r2_dot2_d2.scale(scale)1815 b_dot2_d2.scale(scale)18161817 r_dot2_d2.next_to(r2_dot2_d2,LEFT,1)1818 b_dot2_d2.next_to(r2_dot2_d2,RIGHT,1)18191820 _dots_d2=VGroup(r_dot2_d2,r2_dot2_d2,b_dot2_d2)18211822 _dots_d2.move_to(DOWN*2)18231824 arr_d1=TextMobject("$$\\rightarrow$$")1825 arr_d1.scale(arr_sc)1826 d_f_g=VGroup(_dots,_dots_d2)1827 arr_d1.move_to(d_f_g.get_center())18281829 self.play(ShowCreation(arr_d1))18301831 self.play(ShowCreation(_dots_d2))18321833 self.wait(2)18341835 r_dot_u3=Dot(color=BLUE)1836 b_dot_u3=Dot(color=BLUE)1837 b2_dot_u3=Dot(color=RED)18381839 scale=418401841 r_dot_u3.scale(scale)1842 b_dot_u3.scale(scale)1843 b2_dot_u3.scale(scale)18441845 r_dot_u3.next_to(b_dot_u3,LEFT,1)1846 b2_dot_u3.next_to(b_dot_u3,RIGHT,1)18471848 dots_u3=VGroup(r_dot_u3,b_dot_u3,b2_dot_u3)18491850 dots_u3.shift(UP*2+RIGHT*(ORIGIN-(dots.get_center()+DOWN*2)))18511852 arr_u2=TextMobject("$$\\rightarrow$$")1853 arr_u2.scale(arr_sc)1854 u_f_g=VGroup(dots_u2,dots_u3)1855 arr_u2.move_to(u_f_g.get_center())18561857 self.play(ShowCreation(arr_u2))18581859 self.play(ShowCreation(dots_u3))18601861 self.wait()18621863 r_dot2_d3=Dot(color=RED)1864 r2_dot2_d3=Dot(color=BLUE)1865 b_dot2_d3=Dot(color=RED)18661867 r_dot2_d3.scale(scale)1868 r2_dot2_d3.scale(scale)1869 b_dot2_d3.scale(scale)18701871 r_dot2_d3.next_to(r2_dot2_d3,LEFT,1)1872 b_dot2_d3.next_to(r2_dot2_d3,RIGHT,1)18731874 _dots_d3=VGroup(r_dot2_d3,r2_dot2_d3,b_dot2_d3)18751876 _dots_d3.move_to(DOWN*2+RIGHT*(ORIGIN-(dots.get_center()+DOWN*2)))18771878 arr_d2=TextMobject("$$\\rightarrow$$")1879 arr_d2.scale(arr_sc)1880 d_f_g=VGroup(_dots_d2,_dots_d3)1881 arr_d2.move_to(d_f_g.get_center())18821883 self.play(ShowCreation(arr_d2))18841885 self.play(ShowCreation(_dots_d3))18861887 self.wait(3)18881889 buff=0.3518901891 f_g=VGroup(dots,_dots)1892 box1=Rectangle(width=dots.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)1893 box1.move_to(f_g.get_center())18941895 box2=Rectangle(width=dots.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)1896 box2.move_to(ORIGIN)18971898 box3=Rectangle(width=dots.get_width()+buff,height=f_g.get_height()+buff,color=BLUE)1899 box3.move_to(RIGHT*(ORIGIN-f_g.get_center()))19001901 self.play(ShowCreation(box1))1902 self.play(ShowCreation(box2))1903 self.play(ShowCreation(box3))19041905 self.wait(3)19061907 self.play(FadeOut(box1),FadeOut(box2),FadeOut(box3))19081909 exr1=Dot(color=RED)1910 exr2=Dot(color=RED)1911 exr3=Dot(color=RED)19121913 exb1=Dot(color=BLUE)1914 exb2=Dot(color=BLUE)1915 exb3=Dot(color=BLUE)19161917 exr1.scale(scale)1918 exr2.scale(scale)1919 exr3.scale(scale)1920 exb1.scale(scale)1921 exb2.scale(scale)1922 exb3.scale(scale)19231924 exr1.next_to(exr2,LEFT,1)1925 exr3.next_to(exr2,RIGHT,1)19261927 exb1.next_to(exb2,LEFT,1)1928 exb3.next_to(exb2,RIGHT,1)19291930 exr=VGroup(exr1,exr2,exr3)1931 exb=VGroup(exb1,exb2,exb3)19321933 exr.shift(LEFT*4+DOWN*4)19341935 exb.shift(RIGHT*4+DOWN*4)19361937 self.play(ShowCreation(exr),ShowCreation(exb))19381939 self.wait(2)19401941 self.play(FadeOut(exr),FadeOut(exb))19421943 self.wait(3)19441945 a=TextMobject("$$a$$")1946 a.scale(3)19471948 p=TextMobject("$$p$$",color=BLUE)1949 p.scale(3)19501951 pers.sep_exp(a,p)19521953 ap=VGroup(a,p)1954 min_a=TextMobject("$$-a$$")1955 min_a.scale(3)1956 min_a.next_to(ap,RIGHT,0.1)1957 min_a.align_to(ap,DOWN)19581959 exp=VGroup(a,p,min_a)19601961 exp.move_to(ORIGIN)19621963 self.play(Write(ap))1964 self.wait()1965 self.play(Write(min_a))19661967 self.wait(3)19681969#python -m manim MITintegral\Fermat\fermatscenes.py IssueFour -pl1970class IssueFour(MovingCameraScene):1971 def setup(self):1972 MovingCameraScene.setup(self)1973 def construct(self):19741975 set1=pers.construct_dots("r","r","b","b",0,0)19761977 self.play(ShowCreation(set1))19781979 self.wait(2)19801981 self.play(ApplyMethod(set1.scale,0.5))19821983 self.play(ApplyMethod(set1.move_to,LEFT*5+UP*2))19841985 self.wait(2)19861987 set2=pers.construct_dots("r","b","r","b",0,0)1988 set2.scale(0.5)1989 set2.move_to(LEFT*5+UP*1.33333*0.5)19901991 set3=pers.construct_dots("r","r","r","b",0,0)1992 set3.scale(0.5)1993 set3.move_to(LEFT*5+DOWN*1.3333*0.5)19941995 set4=pers.construct_dots("b","b","b","r",0,0)1996 set4.scale(0.5)1997 set4.move_to(LEFT*5+DOWN*2)19981999 self.play(ShowCreation(set2))2000 self.play(ShowCreation(set3))2001 self.play(ShowCreation(set4))20022003 self.wait(3)20042005 ####2006 #Row120072008 set11=pers.construct_dots("b","r","r","b",0,0)2009 set11.move_to(UP*2)2010 set11.scale(0.5)20112012 arr1=pers.arrow_maker(set1,set11,WHITE)20132014 self.play(ShowCreation(arr1))2015 self.play(ShowCreation(set11))20162017 self.wait(2)20182019 elli=TextMobject("...")2020 elli.scale(4)2021 elli.move_to(RIGHT*5+UP*2)20222023 arr11=pers.arrow_maker(set11,elli,WHITE)2024 arr11.shift(RIGHT*0.8)20252026 self.play(ShowCreation(arr11))2027 self.play(ShowCreation(elli))20282029 self.wait(3)20302031 #####2032 #Row 320332034 set31=pers.construct_dots("b","r","r","r",0,0)2035 set31.scale(0.5)2036 set31.move_to(DOWN*0.5*1.3333)2037 arr3=pers.arrow_maker(set3,set31,WHITE)20382039 self.play(ShowCreation(arr3))2040 self.play(ShowCreation(set31))20412042 self.wait()20432044 elli3=TextMobject("...")2045 elli3.scale(4)2046 elli3.move_to(RIGHT*5+DOWN*0.5*1.3333)20472048 arr31=pers.arrow_maker(set31,elli3,WHITE)2049 arr31.shift(RIGHT*0.8)20502051 self.play(ShowCreation(arr31))2052 self.play(ShowCreation(elli3))20532054 #####2055 #Row 420562057 set41=pers.construct_dots("r","b","b","b",0,0)2058 set41.scale(0.5)2059 set41.move_to(DOWN*2)2060 arr4=pers.arrow_maker(set4,set41,WHITE)20612062 self.play(ShowCreation(arr4))2063 self.play(ShowCreation(set41))20642065 self.wait()20662067 elli4=TextMobject("...")2068 elli4.scale(4)2069 elli4.move_to(RIGHT*5+DOWN*2)20702071 arr41=pers.arrow_maker(set41,elli4,WHITE)2072 arr41.shift(RIGHT*0.8)20732074 self.play(ShowCreation(arr41))2075 self.play(ShowCreation(elli4))20762077 self.wait(3)20782079 set21=pers.construct_dots("b","r","b","r",0,0)2080 set21.scale(0.5)2081 set21.move_to(UP*0.5*1.33333)20822083 arr2=pers.arrow_maker(set2,set21,WHITE)20842085 self.play(ShowCreation(arr2))2086 self.play(ShowCreation(set21))20872088 self.wait(3)20892090 buff=0.352091 col1=VGroup(set1,set4)2092 box1=Rectangle(width=col1.get_width()+buff,height=col1.get_height()+buff,color=BLUE)2093 box1.move_to(col1.get_center())20942095 box2=Rectangle(width=col1.get_width()+buff,height=col1.get_height()+buff,color=BLUE)20962097 box3=Rectangle(width=elli.get_width()+buff,height=elli.get_height()+buff,color=BLUE)2098 box3.move_to(elli.get_center())20992100 ellis=VGroup(elli3,elli4)2101 box4=Rectangle(width=ellis.get_width()+buff,height=ellis.get_height()+buff,color=BLUE)2102 box4.move_to(ellis.get_center())21032104 self.play(ShowCreation(box1))2105 self.play(ShowCreation(box2))21062107 self.wait(2)21082109 self.play(ShowCreation(box3),ShowCreation(box4))2110 2111 self.wait(3)21122113 self.play(2114 FadeOut(box1),2115 FadeOut(box2),2116 FadeOut(box3),2117 FadeOut(box4)2118 )21192120 self.play(2121 ApplyMethod(set1.shift,UP),2122 ApplyMethod(set2.shift,UP),2123 ApplyMethod(set3.shift,DOWN),2124 ApplyMethod(set4.shift,DOWN),21252126 ApplyMethod(set11.shift,UP),2127 ApplyMethod(set21.shift,UP),2128 ApplyMethod(set31.shift,DOWN),2129 ApplyMethod(set41.shift,DOWN),21302131 ApplyMethod(arr1.shift,UP),2132 ApplyMethod(arr2.shift,UP),2133 ApplyMethod(arr3.shift,DOWN),2134 ApplyMethod(arr4.shift,DOWN),21352136 ApplyMethod(arr11.shift,UP),2137 ApplyMethod(arr31.shift,DOWN),2138 ApplyMethod(arr41.shift,DOWN),21392140 ApplyMethod(elli.shift,UP),2141 ApplyMethod(elli3.shift,DOWN),2142 ApplyMethod(elli4.shift,DOWN)21432144 )21452146 self.wait()21472148 a=TextMobject("$$a$$")2149 a.scale(3)21502151 p=TextMobject("$$p$$",color=BLUE)2152 p.scale(3)21532154 pers.sep_exp(a,p)21552156 ap=VGroup(a,p)2157 min_a=TextMobject("$$-a$$")2158 min_a.scale(3)2159 min_a.next_to(ap,RIGHT,0.1)2160 min_a.align_to(ap,DOWN)21612162 exp=VGroup(a,p,min_a)21632164 exp.move_to(ORIGIN)21652166 self.play(Write(ap))2167 self.wait()2168 self.play(Write(min_a))21692170 self.wait(3)21712172#python -m manim MITintegral\Fermat\fermatscenes.py Primes -pl2173class Primes(MovingCameraScene):2174 def setup(self):2175 MovingCameraScene.setup(self)2176 def construct(self):2177 a=TextMobject("$$2,$$")2178 b=TextMobject("$$3,$$")2179 c=TextMobject("$$5,$$")2180 d=TextMobject("$$7,$$")2181 e=TextMobject("$$11,$$")2182 f=TextMobject("$$13,$$")2183 g=TextMobject("$$17,$$")2184 h=TextMobject("$$...$$")21852186 scale=22187 a.scale(2)2188 b.scale(2)2189 c.scale(2)2190 d.scale(2)2191 e.scale(2)2192 f.scale(2)2193 g.scale(2)2194 h.scale(2)21952196 buff=0.421972198 b.next_to(a,RIGHT,buff)2199 c.next_to(b,RIGHT,buff)2200 d.next_to(c,RIGHT,buff)2201 e.next_to(d,RIGHT,buff)2202 f.next_to(e,RIGHT,buff)2203 g.next_to(f,RIGHT,buff)2204 h.next_to(g,RIGHT,buff)22052206 group=VGroup(a,b,c,d,e,f,g,h)22072208 group.move_to(ORIGIN)22092210 self.play(Write(a))2211 self.play(Write(b))2212 self.play(Write(c))2213 self.play(Write(d))2214 self.play(Write(e))2215 self.play(Write(f))2216 self.play(Write(g))2217 self.play(Write(h))22182219 self.wait(2)22202221 i=TextMobject("$$+1$$")2222 j=TextMobject("$$+2$$")2223 k=TextMobject("$$+2$$")2224 l=TextMobject("$$+4$$")2225 m=TextMobject("$$+2$$")2226 n=TextMobject("$$+4$$")22272228 i.scale(scale)2229 j.scale(scale)2230 k.scale(scale)2231 l.scale(scale)2232 m.scale(scale)2233 n.scale(scale)22342235 buf=0.322362237 i.next_to(a,UP,buf)2238 j.next_to(b,UP,buf)2239 k.next_to(c,UP,buf)2240 l.next_to(d,UP,buf)2241 m.next_to(e,UP,buf)2242 n.next_to(f,UP,buf)22432244 adds=VGroup(i,j,k,l,m,n)22452246 adds.shift(RIGHT*0.15)22472248 self.play(ShowCreation(i))22492250 self.play(Transform(i,j))2251 self.play(Transform(i,k))2252 adds.shift(RIGHT*0.1)2253 self.play(Transform(i,l))2254 self.play(Transform(i,m))2255 self.play(Transform(i,n))22562257 self.wait(3)22582259#python -m manim MITintegral\Fermat\fermatscenes.py Test -pl2260class Test(Scene):2261 def construct(self):2262 dot=Dot()2263 dot.move_to(RIGHT+UP)2264 grace=0.12265 if pers.abs(dot.get_center())<(np.sqrt(2)+grace) and pers.abs(dot.get_center())>(np.sqrt(2)-grace):2266 self.play(ShowCreation(dot))2267
...
Jigsaw.py
Source:Jigsaw.py
...15 self.play(ReplacementTransform(title, title_02), run_time=1.)16 self.wait(0.4)17 A, B, C, D = Dot(UP * 1.6 + RIGHT * 0.8), Dot(UP * 1. + RIGHT * 2.), Dot(RIGHT * 2.7), Dot(DOWN * 0.8)18 ABCD = VGroup(A, B, C, D).to_corner(DOWN * 2.4 + LEFT * 1.8).set_fill(opacity=0)19 quadrilateral = Polygon(A.get_center(), B.get_center(), C.get_center(), D.get_center())\20 .add_updater(lambda p: p.become(Polygon(A.get_center(), B.get_center(), C.get_center(), D.get_center(),21 color=BLUE, fill_color=BLUE, fill_opacity=1.0)))22 self.play(TransformFromCopy(t4a_1[1:], quadrilateral), FadeIn(ABCD), run_time=1)23 self.wait(0.2)24 self.play(A.shift, UP * 0.5, B.shift, UR * 0.3, rate_func=there_and_back, run_time=0.7)25 self.wait(0.1)26 circle = Circle().move_to(D).rotate(PI).shift(RIGHT)27 self.play(MoveAlongPath(D, circle), run_time=0.75)28 arrow = Arrow(ORIGIN, RIGHT * 5, color=ORANGE, buff=0).next_to(quadrilateral, RIGHT * 1.6)29 parallelogram = Polygon(RIGHT + UP * 2, RIGHT * 3.5 + UP * 2, RIGHT * 2.5, ORIGIN,30 color=BLUE, fill_color=BLUE, fill_opacity=1.0).next_to(arrow, RIGHT * 1.2)31 arrow.shift(DOWN * 0.8)32 text = Text('å两åï¼éæ°æ¼æ¥', font='ææºé»ä½ Bold', size=0.36).move_to(arrow).shift(UP * 0.4)33 E = self.get_point_on_line(A, B, 0.3)34 F = self.get_point_on_line(B, C, 0.35)35 G = self.get_point_on_line(C, D, 0.3)36 H = self.get_point_on_line(D, A, 0.6)37 I = self.intersection(E, G, F, H)38 cut_line_01 = Line(E, G, color=YELLOW).scale(2)39 cut_line_02 = Line(H, F, color=YELLOW).scale(2)40 poly_1 = Polygon(A.get_center(), E.get_center(), I.get_center(), H.get_center(), color=BLUE, fill_color=BLUE, fill_opacity=1.0)41 poly_2 = Polygon(E.get_center(), B.get_center(), F.get_center(), I.get_center(), color=BLUE, fill_color=BLUE, fill_opacity=1.0)42 poly_3 = Polygon(H.get_center(), I.get_center(), G.get_center(), D.get_center(), color=BLUE, fill_color=BLUE, fill_opacity=1.0)43 poly_4 = Polygon(I.get_center(), F.get_center(), C.get_center(), G.get_center(), color=BLUE, fill_color=BLUE, fill_opacity=1.0)44 fragments = VGroup(poly_1, poly_2, poly_3, poly_4)45 fragments_02 = fragments.copy().arrange(RIGHT * 0.35).scale(0.95).next_to(text, UP)46 self.play(ShowCreation(arrow), run_time=1)47 t4a = self.ShiftInOneByOne_new(text, shift_vect=DOWN * 0.8, run_speed=0.2)48 self.play(ShowCreationThenDestruction(cut_line_01), ShowCreationThenDestruction(cut_line_02), run_time=0.72)49 # self.add(cut_line_01, cut_line_02)50 self.play(TransformFromCopy(fragments, fragments_02), run_time=1)51 self.wait(0.2)52 self.play(TransformFromCopy(fragments_02, parallelogram), run_time=1)53 self.play(FadeOutRandom(title_02[0]), FadeOutRandom(title_02[1]), FadeOutRandom(title_02[2]), run_time=1.2)54 text_how = Text('å¦ä½åï¼å¦ä½æ¼ï¼', font='ææºé»ä½ Bold', size=1.2).to_corner(UP * 2.4 + LEFT * 2)55 self.ShiftInOneByOne_new(text_how, run_speed=0.3, wait_time=0.1)56 # self.play(WiggleOutThenIn(t4a_how), run_time=0.9)57 self.Countdown_anim()58 self.wait(2)59 def get_point_on_line(self, P1, P2, t=0.5, **kwargs):60 try:61 return Dot(P1.get_center() + t * (P2.get_center() - P1.get_center()), **kwargs)62 except:63 return Dot(P1 + t * (P2 - P1), **kwargs)64 def intersection(self, P1, P2, P3, P4, **kwargs):65 try:66 return Dot(line_intersection([P1.get_center(), P2.get_center()], [P3.get_center(), P4.get_center()]), **kwargs)67 except:68 return Dot(line_intersection([P1, P2], [P3, P4]), **kwargs)69 def Countdown_anim(self, time=5):70 num = VGroup(*[Text(str(i), font='ææºé»ä½ Bold', color=GREEN).set_height(1.2) for i in range(time, 0, -1)]).to_corner(RIGHT * 1.25 + UP * 1.25, buff=1)71 circle = Circle(radius=1).move_to(num).set_stroke(GREEN, 16)72 for i in range(time):73 self.add(num[i])74 self.play(WiggleOutThenIn(num[i]), ShowCreationThenDestruction(circle), run_time=1)75 self.remove(num[i])76class Intro(Text4animScene):77 def construct(self):78 t2c = {'ä»»æå边形': BLUE, 'å两å': ORANGE, 'å¹³è¡å边形': PINK}79 text_01 = Text('对任æå边形', font='ææºé»ä½ Bold', size=1).to_corner(LEFT * 2 + UP * 3.5)80 text_02 = Text('å¦ä½è½å¨å两åä¹å', font='ææºé»ä½ Bold', size=1).next_to(text_01, DOWN * 1.8, aligned_edge=LEFT)81 text_03 = Text('å°ç¢çéæ°æ¼æå¹³è¡å边形', font='ææºé»ä½ Bold', size=1).next_to(text_02, DOWN * 1.8, aligned_edge=LEFT)82 text_01.set_color_by_t2c(t2c), text_02.set_color_by_t2c(t2c), text_03.set_color_by_t2c(t2c)83 t4a_1 = self.ShiftInOneByOne_new(text_01, run_speed=0.3, wait_time=0.0)84 t4a_2 = self.ShiftInOneByOne_new(text_02, run_speed=0.26, wait_time=0.0)85 t4a_3 = self.ShiftInOneByOne_new(text_03, run_speed=0.23, wait_time=0.9)86 title = VGroup(t4a_1, t4a_2, t4a_3)87 title_02 = title.copy().scale(0.6).to_corner(LEFT * 1.5 + UP * 1.5)88 self.play(ReplacementTransform(title, title_02), run_time=0.8)89 self.wait(0.4)90 A, B, C, D = Dot(UP * 1.6 + RIGHT * 0.8), Dot(UP * 1. + RIGHT * 2.), Dot(RIGHT * 2.7), Dot(DOWN * 0.8)91 ABCD = VGroup(A, B, C, D).to_corner(DOWN * 3.2 + LEFT * 1.8).set_fill(opacity=0)92 quadrilateral = Polygon(A.get_center(), B.get_center(), C.get_center(), D.get_center())\93 .add_updater(lambda p: p.become(Polygon(A.get_center(), B.get_center(), C.get_center(), D.get_center(),94 stroke_color=WHITE, stroke_width=4, fill_color=BLUE, fill_opacity=1.0)))95 self.play(TransformFromCopy(t4a_1[1:], quadrilateral), FadeIn(ABCD), run_time=0.8)96 self.wait(0.1)97 # self.play(A.shift, UP * 0.5, B.shift, UR * 0.3, rate_func=there_and_back, run_time=0.7)98 # self.wait(0.1)99 # circle = Circle().move_to(D).rotate(PI).shift(RIGHT)100 # self.play(MoveAlongPath(D, circle), run_time=0.75)101 arrow = Arrow(ORIGIN, RIGHT * 5, color=ORANGE, buff=0).next_to(quadrilateral, RIGHT * 1.6)102 parallelogram = Polygon(RIGHT + UP * 2, RIGHT * 3.5 + UP * 2, RIGHT * 2.5, ORIGIN,103 stroke_color=WHITE, stroke_width=4, fill_color=BLUE, fill_opacity=1.0).next_to(arrow, RIGHT * 1.25)104 arrow.shift(DOWN * 0.8)105 text = Text('å两åï¼éæ°æ¼æ¥', font='ææºé»ä½ Bold', size=0.36).move_to(arrow).shift(UP * 0.4)106 E = self.get_point_on_line(A, B, 0.3)107 F = self.get_point_on_line(B, C, 0.35)108 G = self.get_point_on_line(C, D, 0.3)109 H = self.get_point_on_line(D, A, 0.6)110 I = self.intersection(E, G, F, H)111 cut_line_01 = Line(E, G, color=YELLOW).scale(2)112 cut_line_02 = Line(H, F, color=YELLOW).scale(2)113 poly_1 = Polygon(A.get_center(), E.get_center(), I.get_center(), H.get_center(), stroke_color=WHITE, stroke_width=4, fill_color=BLUE, fill_opacity=1.0)114 poly_2 = Polygon(E.get_center(), B.get_center(), F.get_center(), I.get_center(), stroke_color=WHITE, stroke_width=4, fill_color=BLUE, fill_opacity=1.0)115 poly_3 = Polygon(H.get_center(), I.get_center(), G.get_center(), D.get_center(), stroke_color=WHITE, stroke_width=4, fill_color=BLUE, fill_opacity=1.0)116 poly_4 = Polygon(I.get_center(), F.get_center(), C.get_center(), G.get_center(), stroke_color=WHITE, stroke_width=4, fill_color=BLUE, fill_opacity=1.0)117 fragments = VGroup(poly_1, poly_2, poly_3, poly_4)118 fragments_02 = fragments.copy().arrange(RIGHT * 0.35).scale(0.95).next_to(text, UP)119 self.play(ShowCreation(arrow), run_time=1)120 self.wait(0.1)121 self.play(FadeInFrom(text, direction=UP), run_time=0.8)122 self.wait(0.1)123 self.play(ShowCreationThenDestruction(cut_line_01), ShowCreationThenDestruction(cut_line_02), run_time=0.8)124 # self.add(cut_line_01, cut_line_02)125 self.play(TransformFromCopy(fragments, fragments_02), run_time=0.95)126 self.wait(0.1)127 self.play(TransformFromCopy(fragments_02, parallelogram), run_time=0.95)128 self.play(FadeOutRandom(title_02[0]), FadeOutRandom(title_02[1]), FadeOutRandom(title_02[2]), run_time=1.)129 self.wait(0.1)130 text_how = Text('å¦ä½åï¼å¦ä½æ¼ï¼', font='ææºé»ä½ Bold', size=1.2).to_corner(UP * 2.4 + LEFT * 2)131 self.ShiftInOneByOne_new(text_how, run_speed=0.325, wait_time=0.05)132 # self.play(WiggleOutThenIn(t4a_how), run_time=0.9)133 self.Countdown_anim()134 self.wait(2)135 def get_point_on_line(self, P1, P2, t=0.5, **kwargs):136 try:137 return Dot(P1.get_center() + t * (P2.get_center() - P1.get_center()), **kwargs)138 except:139 return Dot(P1 + t * (P2 - P1), **kwargs)140 def intersection(self, P1, P2, P3, P4, **kwargs):141 try:142 return Dot(line_intersection([P1.get_center(), P2.get_center()], [P3.get_center(), P4.get_center()]), **kwargs)143 except:144 return Dot(line_intersection([P1, P2], [P3, P4]), **kwargs)145 def Countdown_anim(self, time=5):146 num = VGroup(*[Text(str(i), font='ææºé»ä½ Bold', color=GREEN).set_height(1.2) for i in range(time, 0, -1)]).to_corner(RIGHT * 1.25 + UP * 1.25, buff=1)147 circle = Circle(radius=1).move_to(num).set_stroke(GREEN, 16)148 for i in range(time):149 self.add(num[i])150 self.play(WiggleOutThenIn(num[i]), ShowCreationThenDestruction(circle), run_time=1)151 self.remove(num[i])152class How_to(Text4animScene):153 def construct(self):154 """155 1.沿两ç»å¯¹è¾¹çä¸ç¹è¿æçç´çº¿å两å156 2.å½¢æäºå个ç¢ç157 3.æå¾ï¼é¢è²ç¸åçè¾¹é¿åº¦ç¸ç158 红è²è§åé»è²è§äºè¡¥159 ææç´«è²è§ä¹å为360°160 4.å æ¤ï¼ä¸é¾è¯æï¼æç
§å¨ç»éé¢çæ¼æ³ï¼å¾å°çå¾å½¢ä¸ºå¹³è¡å边形161 """162 A, B, C, D = Dot(UP * 1.6 + RIGHT * 0.9), Dot(UP * 0.9 + RIGHT * 2.2), Dot(RIGHT * 2.7 + DOWN * 0.1), Dot(DOWN * 0.8)163 ABCD = VGroup(A, B, C, D).move_to(DOWN * 0.6 + RIGHT * 0.4).scale(2.25)164 # quadrilateral = self.get_poly_d(A, B, C, D) .add_updater(lambda p: p.become(self.get_poly_d(A, B, C, D, stroke_color=WHITE, stroke_width=8, fill_color=BLUE, fill_opacity=1.0)))165 quadrilateral = self.get_poly_d(A, B, C, D, stroke_color=WHITE, stroke_width=4.5, fill_color=BLUE, fill_opacity=0.9)166 E = self.get_point_on_line(A, B, 0.5)167 F = self.get_point_on_line(B, C, 0.5)168 G = self.get_point_on_line(C, D, 0.5)169 H = self.get_point_on_line(D, A, 0.5)170 I = self.intersection(E, G, F, H)171 cut_line_01 = Line(E, G, color=YELLOW).scale(2)172 cut_line_02 = Line(H, F, color=YELLOW).scale(2)173 poly_1 = self.get_poly_d(A, E, I, H, stroke_color=WHITE, stroke_width=4.5, fill_color=BLUE, fill_opacity=0.9)174 poly_2 = self.get_poly_d(E, B, F, I, stroke_color=WHITE, stroke_width=4.5, fill_color=BLUE, fill_opacity=0.9)175 poly_3 = self.get_poly_d(H, I, G, D, stroke_color=WHITE, stroke_width=4.5, fill_color=BLUE, fill_opacity=0.9)176 poly_4 = self.get_poly_d(I, F, C, G, stroke_color=WHITE, stroke_width=4.5, fill_color=BLUE, fill_opacity=0.9)177 fragments = VGroup(poly_1, poly_2, poly_3, poly_4).set_plot_depth(-1)178 # fragments_02 = fragments.copy().arrange(RIGHT * 0.35)179 text = Text('沿两ç»å¯¹è¾¹çä¸ç¹ææçç´çº¿å两å', font='ææºé»ä½ Bold', size=0.56, color=BLUE).to_corner(LEFT * 1.25 + UP * 1.25)180 self.play(FadeInFromLarge(quadrilateral), run_time=1.2)181 self.wait(0.2)182 t4a = self.ShiftInOneByOne_new(text, run_speed=0.25, wait_time=0.15)183 self.play(ShowCreationThenDestruction(cut_line_01), ShowCreationThenDestruction(cut_line_02), FadeIn(fragments), run_time=0.8)184 self.remove(quadrilateral)185 self.play(fragments[0].shift, UL * 0.25, fragments[1].shift, UR * 0.25,186 fragments[2].shift, DL * 0.25, fragments[3].shift, DR * 0.25, run_time=1.6)187 self.wait(0.5)188 text_0 = Text('æå¾ï¼', font='ææºé»ä½ Bold', size=0.4).next_to(text, DOWN * 2, aligned_edge=LEFT)189 text_1 = Text('1.åè²çº¿æ®µçé¿', font='ææºé»ä½ Bold', size=0.4).next_to(text_0, DOWN * 1.6, aligned_edge=LEFT)190 text_1.set_color_by_t2c({'åè²çº¿æ®µ': GREEN})191 text_2 = Text('2.红è§é»è§äºè¡¥', font='ææºé»ä½ Bold', size=0.4).next_to(text_1, DOWN * 1.6, aligned_edge=LEFT)192 text_2.set_color_by_t2c({'红è§': RED, 'é»è§': YELLOW})193 text_3 = Text('3.ç´«è²è§ä¹å为360度', font='ææºé»ä½ Bold', size=0.4).next_to(text_2, DOWN * 1.6, aligned_edge=LEFT)194 text_3.set_color_by_t2c({'ç´«è²è§': PINK})195 text_4 = Text('ä¸éæä½çå¦è', font='ææºé»ä½ Bold', size=0.4).next_to(text_3, DOWN * 1.6, aligned_edge=LEFT)196 text_5 = Text('ç»æççæ¯é常çamazingåï¼', font='ææºé»ä½ Bold', size=0.4).next_to(text_4, DOWN * 1.6, aligned_edge=LEFT)197 text_6 = Text('(ç±ä¸é¢3个ç»è®ºä¸é¾è¯æç»ææ°å¥½ä¸ºå¹³è¡å边形)', font='ææºé»ä½ Bold', size=0.4).next_to(text_5, DOWN * 1.6, aligned_edge=LEFT).set_color(GREEN)198 texts = VGroup(text_0, text_1, text_2, text_3, text_4, text_5, text_6).shift(RIGHT * 0.25)199 lines = VGroup(*[200 Line(A.get_center(), E.get_center(), color=RED, stroke_width=5.4).scale(1.012).shift(UL * 0.25),201 Line(E.get_center(), B.get_center(), color=RED, stroke_width=5.4).scale(1.012).shift(UR * 0.25),202 Line(B.get_center(), F.get_center(), color=YELLOW, stroke_width=5.4).scale(1.012).shift(UR * 0.25),203 Line(F.get_center(), C.get_center(), color=YELLOW, stroke_width=5.4).scale(1.012).shift(DR * 0.25),204 Line(C.get_center(), G.get_center(), color=GREEN, stroke_width=5.4).scale(1.012).shift(DR * 0.25),205 Line(G.get_center(), D.get_center(), color=GREEN, stroke_width=5.4).scale(1.012).shift(DL * 0.25),206 Line(D.get_center(), H.get_center(), color=PINK, stroke_width=5.4).scale(1.012).shift(DL * 0.25),207 Line(H.get_center(), A.get_center(), color=PINK, stroke_width=5.4).scale(1.012).shift(UL * 0.25),208 ]).set_plot_depth(2)209 angles = VGroup(*[210 Angle(H.get_center(), I.get_center(), E.get_center(), color=RED, radius=0.5).shift(UL * 0.25),211 Angle(E.get_center(), I.get_center(), F.get_center(), color=YELLOW, radius=0.5).shift(UR * 0.25),212 Angle(F.get_center(), I.get_center(), G.get_center(), color=RED, radius=0.5).shift(DR * 0.25),213 Angle(G.get_center(), I.get_center(), H.get_center(), color=YELLOW, radius=0.5).shift(DL * 0.25),214 ]).set_plot_depth(4)215 angles_02 = VGroup(*[216 Angle(H.get_center(), A.get_center(), E.get_center(), color=PINK, radius=0.45).shift(UL * 0.25),217 Angle(E.get_center(), B.get_center(), F.get_center(), color=PINK, radius=0.45).shift(UR * 0.25),218 Angle(F.get_center(), C.get_center(), G.get_center(), color=PINK, radius=0.45).shift(DR * 0.25),219 Angle(G.get_center(), D.get_center(), H.get_center(), color=PINK, radius=0.45).shift(DL * 0.25),220 ]).set_plot_depth(6)221 self.play(Write(text_0), run_time=0.9)222 self.wait(0.25)223 self.play(Write(text_1), ShowCreation(lines), run_time=2.1)224 self.wait(1.4)225 self.play(Write(text_2), ShowCreation(angles), run_time=2.2)226 self.wait(1.6)227 self.play(Write(text_3), ShowCreation(angles_02), run_time=2.5)228 self.wait(1.5)229 group_all = VGroup(fragments, lines, angles, angles_02)230 self.play(group_all.shift, RIGHT * 1.2)231 self.wait(0.4)232 self.remove(fragments, lines, angles, angles_02)233 ul = VGroup(fragments[0].set_plot_depth(-1), lines[0].set_plot_depth(1), lines[7].set_plot_depth(1), angles[0].set_plot_depth(2), angles_02[0].set_plot_depth(3))234 ur = VGroup(fragments[1].set_plot_depth(-1), lines[1].set_plot_depth(1), lines[2].set_plot_depth(1), angles[1].set_plot_depth(2), angles_02[1].set_plot_depth(3))235 dr = VGroup(fragments[3].set_plot_depth(-1), lines[3].set_plot_depth(1), lines[4].set_plot_depth(1), angles[2].set_plot_depth(2), angles_02[2].set_plot_depth(3))236 dl = VGroup(fragments[2].set_plot_depth(-1), lines[5].set_plot_depth(1), lines[6].set_plot_depth(1), angles[3].set_plot_depth(2), angles_02[3].set_plot_depth(3))237 self.add(*ul, *ur, *dr, *dl)238 t4a_2 = self.ShiftInOneByOne_new(text_4, run_speed=0.32, wait_time=0.15)239 self.play(Rotating(ul, radians=PI, about_point=(lines[-1].get_start() + lines[-2].get_end())/2, run_time=1.8, rate_func=smooth))240 self.wait(0.2)241 self.play(Rotating(dr, radians=PI, about_point=(lines[3].get_start() + lines[2].get_end())/2, run_time=1.8, rate_func=smooth))242 self.wait(0.4)243 self.play(ur.shift, DOWN * 3, dr.shift, DOWN * 3, ul.shift, UP * 3, dl.shift, UP * 3, run_time=1.5)244 self.wait(0.25)245 p1 = DOWN * 0.65 + RIGHT * 2246 self.play(ur.shift, (p1[0] - lines[2].get_start()[0] - 0.01) * RIGHT,247 dr.shift, (p1[0] - lines[2].get_start()[0] - 0.01) * RIGHT,248 ul.shift, (p1[0] - lines[0].get_start()[0]) * RIGHT,249 dl.shift, (p1[0] - lines[0].get_start()[0]) * RIGHT, run_time=1.5)250 self.wait(0.2)251 self.play(ur.shift, (p1[1] - lines[2].get_start()[1]) * UP,252 dr.shift, (p1[1] - lines[2].get_start()[1]) * UP,253 ul.shift, (p1[1] - lines[0].get_start()[1]) * UP,254 dl.shift, (p1[1] - lines[0].get_start()[1]) * UP, run_time=1.5)255 self.wait(0.1)256 t4a_3 = self.ShiftInOneByOne_new(text_5, run_speed=0.18, wait_time=0.1)257 self.play(WiggleOutThenIn(group_all))258 self.wait(0.4)259 self.play(WriteRandom(text_6), run_time=1.6)260 self.wait(5)261 def get_poly_p(self, p1, p2, p3, p4, **kwargs):262 return New_Polygon(p1, p2, p3, p4, **kwargs)263 def get_poly_d(self, d1, d2, d3, d4, **kwargs):264 return New_Polygon(d1.get_center(), d2.get_center(), d3.get_center(), d4.get_center(), **kwargs)265 def get_point_on_line(self, P1, P2, t=0.5, **kwargs):266 try:267 return Dot(P1.get_center() + t * (P2.get_center() - P1.get_center()), **kwargs)268 except:269 return Dot(P1 + t * (P2 - P1), **kwargs)270 def intersection(self, P1, P2, P3, P4, **kwargs):271 try:272 return Dot(line_intersection([P1.get_center(), P2.get_center()], [P3.get_center(), P4.get_center()]), **kwargs)273 except:274 return Dot(line_intersection([P1, P2], [P3, P4]), **kwargs)275class Tile(How_to):276 def construct(self):277 A, B, C, D = Dot(UP * 1.6 + RIGHT * 0.9), Dot(UP * 0.9 + RIGHT * 2.2), Dot(RIGHT * 2.7 + DOWN * 0.1), Dot(DOWN * 0.8)278 ABCD = VGroup(A, B, C, D).move_to(ORIGIN).scale(1.6)279 # quadrilateral = self.get_poly_d(A, B, C, D) .add_updater(lambda p: p.become(self.get_poly_d(A, B, C, D, stroke_color=WHITE, stroke_width=8, fill_color=BLUE, fill_opacity=1.0)))280 quadrilateral = self.get_poly_d(A, B, C, D, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)281 E = self.get_point_on_line(A, B, 0.5)282 F = self.get_point_on_line(B, C, 0.5)283 G = self.get_point_on_line(C, D, 0.5)284 H = self.get_point_on_line(D, A, 0.5)285 I = self.intersection(E, G, F, H)286 cut_line_01 = Line(E, G, color=YELLOW).scale(2)287 cut_line_02 = Line(H, F, color=YELLOW).scale(2)288 poly_1 = self.get_poly_d(A, E, I, H, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)289 poly_2 = self.get_poly_d(E, B, F, I, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)290 poly_3 = self.get_poly_d(H, I, G, D, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)291 poly_4 = self.get_poly_d(I, F, C, G, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)292 fragments = VGroup(poly_1, poly_2, poly_3, poly_4).set_plot_depth(-1)293 lines = VGroup(*[294 Line(A.get_center(), E.get_center(), color=RED, stroke_width=5.4).scale(1.012),295 Line(E.get_center(), B.get_center(), color=RED, stroke_width=5.4).scale(1.012),296 Line(B.get_center(), F.get_center(), color=YELLOW, stroke_width=5.4).scale(1.012),297 Line(F.get_center(), C.get_center(), color=YELLOW, stroke_width=5.4).scale(1.012),298 Line(C.get_center(), G.get_center(), color=GREEN, stroke_width=5.4).scale(1.012),299 Line(G.get_center(), D.get_center(), color=GREEN, stroke_width=5.4).scale(1.012),300 Line(D.get_center(), H.get_center(), color=PINK, stroke_width=5.4).scale(1.012),301 Line(H.get_center(), A.get_center(), color=PINK, stroke_width=5.4).scale(1.012),302 ]).set_plot_depth(2)303 angles = VGroup(*[304 Angle(H.get_center(), I.get_center(), E.get_center(), color=RED, radius=0.36),305 Angle(E.get_center(), I.get_center(), F.get_center(), color=YELLOW, radius=0.36),306 Angle(F.get_center(), I.get_center(), G.get_center(), color=RED, radius=0.36),307 Angle(G.get_center(), I.get_center(), H.get_center(), color=YELLOW, radius=0.36),308 ]).set_plot_depth(4)309 angles_02 = VGroup(*[310 Angle(H.get_center(), A.get_center(), E.get_center(), color=PINK, radius=0.36),311 Angle(E.get_center(), B.get_center(), F.get_center(), color=PINK, radius=0.36),312 Angle(F.get_center(), C.get_center(), G.get_center(), color=PINK, radius=0.36),313 Angle(G.get_center(), D.get_center(), H.get_center(), color=PINK, radius=0.36),314 ]).set_plot_depth(6)315 group_all = VGroup(fragments, lines, angles, angles_02)316 self.add(group_all)317 group_all_02 = group_all.copy()318 self.play(Rotating(group_all_02, radians=PI, about_point=lines[0].get_end(), run_time=2))319 group_all_02.shift(LEFT * 0.01)320 self.wait(0.5)321 group_all_03 = group_all.copy()322 self.play(Rotating(group_all_03, radians=PI, about_point=lines[2].get_end(), run_time=2))323 group_all_03.shift(UP * 0.01)324 self.wait(0.5)325 group_all_04 = group_all_03.copy()326 self.play(Rotating(group_all_04, radians=PI, about_point=group_all_03[1][4].get_end(), run_time=2))327 group_all_04.shift(DL * 0.013)328 self.wait(0.5)329 # ul = VGroup(fragments[0].set_plot_depth(-1), lines[0].set_plot_depth(1), lines[7].set_plot_depth(1), angles[0].set_plot_depth(2), angles_02[0].set_plot_depth(3))330 # ur = VGroup(fragments[1].set_plot_depth(-1), lines[1].set_plot_depth(1), lines[2].set_plot_depth(1), angles[1].set_plot_depth(2), angles_02[1].set_plot_depth(3))331 # dr = VGroup(fragments[3].set_plot_depth(-1), lines[3].set_plot_depth(1), lines[4].set_plot_depth(1), angles[2].set_plot_depth(2), angles_02[2].set_plot_depth(3))332 # dl = VGroup(fragments[2].set_plot_depth(-1), lines[5].set_plot_depth(1), lines[6].set_plot_depth(1), angles[3].set_plot_depth(2), angles_02[3].set_plot_depth(3))333 # self.add(*ul, *ur, *dr, *dl)334 all = VGroup(group_all, group_all_02, group_all_03, group_all_04)335 self.play(all.move_to, ORIGIN)336 self.wait(0.5)337 v_x, v_y = F.get_center() - H.get_center(), E.get_center() - G.get_center()338 vects =np.array([-v_x + v_y, v_y, v_x + v_y,339 -v_x, v_x,340 -v_x - v_y, -v_y, v_x - v_y]) * 2341 for vect in vects:342 all_i = all.copy()343 self.play(all_i.shift, vect, run_time=1.)344 self.wait(0.2)345 self.wait(4)346class Tile_02(How_to):347 def construct(self):348 A, B, C, D = Dot(UP * 1.6 + RIGHT * 0.9), Dot(UP * 0.9 + RIGHT * 2.2), Dot(RIGHT * 2.7 + DOWN * 0.1), Dot(DOWN * 0.8)349 ABCD = VGroup(A, B, C, D).move_to(ORIGIN).scale(1.6)350 # quadrilateral = self.get_poly_d(A, B, C, D) .add_updater(lambda p: p.become(self.get_poly_d(A, B, C, D, stroke_color=WHITE, stroke_width=8, fill_color=BLUE, fill_opacity=1.0)))351 quadrilateral = self.get_poly_d(A, B, C, D, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)352 E = self.get_point_on_line(A, B, 0.5)353 F = self.get_point_on_line(B, C, 0.5)354 G = self.get_point_on_line(C, D, 0.5)355 H = self.get_point_on_line(D, A, 0.5)356 I = self.intersection(E, G, F, H)357 cut_line_01 = Line(E, G, color=YELLOW).scale(2)358 cut_line_02 = Line(H, F, color=YELLOW).scale(2)359 poly_1 = self.get_poly_d(A, E, I, H, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)360 poly_2 = self.get_poly_d(E, B, F, I, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)361 poly_3 = self.get_poly_d(H, I, G, D, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)362 poly_4 = self.get_poly_d(I, F, C, G, stroke_color=WHITE, stroke_width=3.6, fill_color=BLUE, fill_opacity=0.8)363 fragments = VGroup(poly_1, poly_2, poly_3, poly_4).set_plot_depth(-1)364 lines = VGroup(*[365 Line(A.get_center(), E.get_center(), color=RED, stroke_width=5.4).scale(1.012),366 Line(E.get_center(), B.get_center(), color=RED, stroke_width=5.4).scale(1.012),367 Line(B.get_center(), F.get_center(), color=YELLOW, stroke_width=5.4).scale(1.012),368 Line(F.get_center(), C.get_center(), color=YELLOW, stroke_width=5.4).scale(1.012),369 Line(C.get_center(), G.get_center(), color=GREEN, stroke_width=5.4).scale(1.012),370 Line(G.get_center(), D.get_center(), color=GREEN, stroke_width=5.4).scale(1.012),371 Line(D.get_center(), H.get_center(), color=PINK, stroke_width=5.4).scale(1.012),372 Line(H.get_center(), A.get_center(), color=PINK, stroke_width=5.4).scale(1.012),373 ]).set_plot_depth(2)374 angles = VGroup(*[375 Angle(H.get_center(), I.get_center(), E.get_center(), color=RED, radius=0.36),376 Angle(E.get_center(), I.get_center(), F.get_center(), color=YELLOW, radius=0.36),377 Angle(F.get_center(), I.get_center(), G.get_center(), color=RED, radius=0.36),378 Angle(G.get_center(), I.get_center(), H.get_center(), color=YELLOW, radius=0.36),379 ]).set_plot_depth(4)380 angles_02 = VGroup(*[381 Angle(H.get_center(), A.get_center(), E.get_center(), color=PINK, radius=0.36),382 Angle(E.get_center(), B.get_center(), F.get_center(), color=PINK, radius=0.36),383 Angle(F.get_center(), C.get_center(), G.get_center(), color=PINK, radius=0.36),384 Angle(G.get_center(), D.get_center(), H.get_center(), color=PINK, radius=0.36),385 ]).set_plot_depth(6)386 ul = VGroup(fragments[0].set_plot_depth(-1), lines[0].set_plot_depth(1), lines[7].set_plot_depth(1), angles[0].set_plot_depth(2), angles_02[0].set_plot_depth(3))387 ur = VGroup(fragments[1].set_plot_depth(-1), lines[1].set_plot_depth(1), lines[2].set_plot_depth(1), angles[1].set_plot_depth(2), angles_02[1].set_plot_depth(3))388 dr = VGroup(fragments[3].set_plot_depth(-1), lines[3].set_plot_depth(1), lines[4].set_plot_depth(1), angles[2].set_plot_depth(2), angles_02[2].set_plot_depth(3))389 dl = VGroup(fragments[2].set_plot_depth(-1), lines[5].set_plot_depth(1), lines[6].set_plot_depth(1), angles[3].set_plot_depth(2), angles_02[3].set_plot_depth(3))390 self.add(*ul, *ur, *dr, *dl)391 self.wait(0.6)392 self.play(Rotating(ul, radians=PI, about_point=(lines[-1].get_start() + lines[-2].get_end())/2, run_time=1.6, rate_func=smooth))393 self.wait(0.2)394 self.play(Rotating(dr, radians=PI, about_point=(lines[3].get_start() + lines[2].get_end())/2, run_time=1.6, rate_func=smooth))395 self.wait(0.4)396 p1 = DL * 0.8397 all = VGroup(ul, ur, dr, dl)398 self.play(ur.shift, p1 - lines[2].get_start() + LEFT * 0.01,399 dr.shift, p1 - lines[2].get_start() + LEFT * 0.01,400 ul.shift, p1 - lines[0].get_start(),401 dl.shift, p1 - lines[0].get_start(), run_time=1.5)402 self.wait(1)403 all_02 = all.copy()404 self.play(Rotating(all_02, radians=PI, about_point=lines[5].get_start(), run_time=1.5, rate_func=smooth))405 all_02.shift(DL * 0.01)406 self.wait(0.4)407 v_x, v_y = F.get_center() - H.get_center(), E.get_center() - G.get_center()408 all_03 = all.copy()409 self.play(all_03.shift, v_x + v_y + 0.01 * RIGHT, run_time=1.6)410 self.wait(0.4)411 all_04 = all_02.copy()412 self.play(all_04.shift, -v_x + v_y + 0.01 * LEFT, run_time=1.6)413 self.wait(0.6)414 all_group = VGroup(all, all_02, all_03, all_04)415 self.play(all_group.move_to, ORIGIN)416 self.wait(0.5)417 ploy4 = VGroup(all[3], all_02[2], all_03[1], all_04[0])418 self.play(WiggleOutThenIn(ploy4))419 self.wait(0.5)420 vects =np.array([-v_x + v_y, v_y, v_x + v_y,421 -v_x, v_x,...
bg79_cover.py
Source:bg79_cover.py
1from manimlib.imports import *2class Cover(Scene):3 def construct(self):4 t = TextMobject(*[str(x+1) for x in range(6)])5 t[1].move_to(t[0].get_center() + DL*1.5)6 t[2].move_to(t[0].get_center() + DR*1.5)7 arrow1 = Arrow(t[0].get_center(), t[1].get_center())8 arrow1.set_color(RED)9 arrow2 = Arrow(t[0].get_center(), t[2].get_center())10 t[3].move_to(t[1].get_center() + DL)11 t[4].move_to(t[1].get_center() + DR)12 t[5].move_to(t[2].get_center() + DL)13 arrow3 = Arrow(t[1].get_center(), t[3].get_center())14 arrow4 = Arrow(t[1].get_center(), t[4].get_center())15 arrow5 = Arrow(t[2].get_center(), t[5].get_center())16 tree = VGroup(t, arrow1, arrow2, arrow3, arrow4, arrow5)17 self.play(Write(tree))18 l1 = Line()19 l2 = Line()20 l2.move_to(l1.get_center())21 l2.rotate(90*DEGREES)22 cross = VGroup(l1, l2)23 cross.set_color(GREEN)24 cross.scale(0.4)25 cross.rotate(25*DEGREES)26 cross.move_to((t[0].get_center() + t[1].get_center())/2)27 self.play(Write(cross))28 t = TextMobject(r'Max\\ ', 'Product')29 t.scale(3)30 t.set_color(BLUE)31 t.shift(UP*1.5)32 self.play(Write(t))33 r = Rectangle(height=1.3, width=3.3)34 r.move_to(t[0].get_center())35 r.set_color(YELLOW)36 self.play(Write(r))37 tree = VGroup(tree, cross)38 tree.move_to(t.get_center()+DOWN*3.3)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!