def construct(self): if 1 == 1: try: self.add_sound( "sidewayoutput\\basicmanim\\functions001a_01_01_01_01_01.wav", time_offset=19) except: pass self.play(StartScreens01( [], [], [[r"\textbf{\textit{Basic-Manim from }\{Sideway\}}"], [r"\textbf{\textit{Functions}}\\{{Part\ \textspA{I}a}"], [r"\tiny{\textrm{basic-manim.210300151v0\_functions001a}}"], [], [r"\scriptsize{\textbf{Warning:\ The\ content\ may\ contain\ errors,\ mistakes\ and\ inaccuracies.\ Information\ must\ be\ verified\ and\ evaluated\ before\ use.}}"]],)) if 1 == 1: self.grow(r"\titleA{Functions}", shift=[0, 3.6, 0]) rows, cols = (4, 3) x0, y0 = axes_point([1.1, 4.5, cols-1, -4.2], [2.5, -1.8, rows]) txty = [r"ParametricCurve \\\tiny(replacing ParametricFunction)", "ParametricFunction", "FunctionGraph", "FunctionsGraph"] strs = ["\\parbox{25em}{"+txty[i].split(" ", 1)[0]+"("+each+")" for i, each in enumerate([r"\bR{lambda t:[t,t**2,0],\bR{(-1,1,0.01)", r"\bR{lambda t:[t,t**2,0],\bR{t\_min=-1, t\_max=1", r"\bR{lambda t:t**2,\bR{(-1,1,0.01)", r"\bR{'lambda t:t, (-1,0,0.01)',\bR{'lambda t:0, (0,1,0.01)'"])] self.fadein( *[TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0))], run_time=5) self.grow(*[TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0))], *[GeomPoint().move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0))], ) strs = [strs[i].replace("\\bR{", "").replace("\\parbox{25em}{", "").replace( "\\", "")+".shift(["+','.join(map(str, each))+"])" for i, each in enumerate(coord_grid(x0[2:3], y0))] exec("self.create(" + ','.join(strs) + ", run_time=48, lag_ratio=0)") self.fadeout() if 1 == 1: self.play(EndScreen01()) self.wait(5)
def construct(self): if 1 == 1: try: self.add_sound( "sidewayoutput\\basicmanim\\transform001b_01_01_02_01_01.wav", time_offset=18) self.add_sound( "sidewayoutput\\basicmanim\\transform001b_01_01_02_02_01.wav", time_offset=48) self.add_sound( "sidewayoutput\\basicmanim\\transform001b_01_01_02_02_02.wav", time_offset=93) self.add_sound( "sidewayoutput\\basicmanim\\transform001b_01_01_02_03_01.wav", time_offset=148) except: pass self.play( StartScreens01( [], [], [[r"\textbf{\textit{Basic-Manim from }\{Sideway\}}"], [r"\textbf{\textit{Transform}}\\{Part\ \textspA{I}b}"], [ r"\tiny{\textrm{basic-manim.210201951v0\_transform001b}}" ], [], [ r"\scriptsize{\textbf{Warning:\ The\ content\ may\ contain\ errors,\ mistakes\ and\ inaccuracies.\ Information\ must\ be\ verified\ and\ evaluated\ before\ use.}}" ]], )) if 1 == 1: self.play( GrowFromCenter( TextMobject( r"\textit{\textbf{\underline{Apply\ Transform}}}"). shift([0, 3.6, 0]))) rows, cols = (7, 3) x = 5. x0, y0 = axes_point([-2.5, x, cols - 1, -5], [2., -1.1, rows - 1, 3]) txtx = ["\\underline{state 1}", "\\underline{state 2}"] txty = ["Method", "ApplyMethod", "ApplyFunction"] a1 = [ "\\normalsize{sq[0]}", "\\normalsize{sq[1]}", "\\normalsize{sq[2]}" ] a2 = [ r"\normalsize{sq[0]\\.shift([" + str(x) + r",\,0,\,0])}", r"\normalsize{ApplyMethod(\\sq[1].shift,\,[" + str(x) + r",\,0,\,0])}", r"\normalsize{ApplyFunction(\\lambda\,mob:\,mob.shift([" + str(x) + r",\,0,\,0]),\,sq[2])}" ] sq = [GeomSquare(0.75) for i in range(3)] self.fadein( *[ TextMobject(txtx[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:], y0[0:1])) ], *[ TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0[1::2])) ], *[GeomPoint(each) for each in coord_grid(x0[1:3], y0[2::2])], *[ MobjectOrChars(np.ravel(list(zip(a1, a2)))[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:3], y0[1::2])) ], *[ sq[i].move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0[2::2])) ], run_time=5) self.play(AnimationGroup( ShowCreation(sq[0].shift([x, 0, 0]), run_time=0), ApplyMethod(sq[1].shift, [x, 0, 0]), ApplyFunction(lambda mob: mob.shift([x, 0, 0]), sq[2])), run_time=15) self.fadeout() if 1 == 1: self.play( GrowFromCenter( TextMobject( r"\textit{\textbf{\underline{Apply Method}}}").shift( [0, 3.6, 0]).add_as_foreground(self))) rows, cols = (8, 2) x0, y0 = axes_point([-1.5, 6, cols], [3, -0.9, rows]) txty = [ MobjectOrChars(each) for each in [ r"FadeToColor(sq[0],\,RED)", r"ScaleInPlace(sq[1],\,0.5))", "ShrinkToCenter(sq[2])", "Restore(sq[3])" ] ] a1 = [ MobjectOrChars("\\normalsize{sq[" + str(i) + "]}") for i in range(4) ] sq = [GeomSquare(0.75) for i in range(4)] self.fadein( *[ to_get_zlist(a1, sq)[i].move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ], *[GeomPoint(each) for each in coord_grid(x0[1:2], y0[1::2])], ) self.wait() sq[3].save_state() self.play(AnimationGroup( IndicateThenFadeOut(TextMobject( r"Transform(sq[3], Circle().scale(0.375).\\move\_to(sq[3]).shift([1, 0, 0])))" ).move_to([x0[0], y0[7], 0]), scale_factor=1, ratio_array=[1, 0]), Transform( sq[3], Circle().scale(0.375).move_to(sq[3]).shift([1, 0, 0]))), run_time=5) self.wait() self.fadein( *[ txty[i].move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0[1::2])) ], ) self.play(AnimationGroup( FadeToColor(sq[0], RED), ScaleInPlace(sq[1], 0.5), ShrinkToCenter(sq[2]), Restore(sq[3]), ), run_time=35) self.fadeout(exclude_mobjs="foreground") if 1 == 1: rows, cols = (6, 2) x0, y0 = axes_point([-1.5, 6, cols], [3, -0.9, rows]) txty = [ MobjectOrChars(each) for each in [ r"ApplyPointwiseFunction(\\lambda\,pointarray:\,pointarray\,+\,[1,\,0,\,0],\,sq[0])", r"ApplyMatrix([[1.23,\,0.9],\,[0,\,1]],\,sq[1])", r"ApplyComplexFunction(lambda pointarray:\\pointarray\,+\,np.complex(1,\,0),\,sq[2])", ] ] a1 = [ MobjectOrChars("\\normalsize{sq[" + str(i) + "]}") for i in range(4) ] sq = [GeomSquare(0.75) for i in range(4)] self.fadein( *[ to_get_zlist(a1, sq)[i].move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ], *[GeomPoint(each) for each in coord_grid(x0[1:2], y0[1::2])], ) self.wait() self.fadein( *[ txty[i].move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0[1::2])) ], ) self.play(AnimationGroup( ApplyPointwiseFunction( lambda pointarray: pointarray + [1, 0, 0], sq[0]), ApplyMatrix([[1.23, 0.9], [0, 1]], sq[1]), ApplyComplexFunction( lambda pointarray: pointarray + np.complex(1, 0), sq[2]), ), run_time=45) self.fadeout() if 1 == 1: self.play( GrowFromCenter( TextMobject( r"\textit{\textbf{\underline{Swap Method}}}").shift( [0, 3.6, 0]))) rows, cols = (2, 2) count = m, n = [2, 6] x0, y0 = axes_point([-3.5, 6, cols], [2.4, -3.7, rows]) geometrys = [GeomLine(), GeomRegularPolygon(n, radius=2)] txty = [ MobjectOrChars(each) for each in [ r"Swap(*sqs)\\ \tiny{(same as CyclicReplace)}", r"CyclicReplace(*sqs)", ] ] titles = [ [ MobjectOrChars("\\normalsize{sq[" + str(i) + "]}") for i in range(m) ], [ MobjectOrChars("\\normalsize{sq[" + str(i) + "]}") for i in range(n) ], ] sqs = [ [GeomSquare(1.) for i in range(m)], [GeomSquare(1.) for i in range(n)], ] [[ sq.add(title).add(GeomPoint()) for sq, title in zip(sqs[i], titles[i]) ] for i in range(len(count))] self.fadein(*[ geometrys[i].move_to(each) for i, each in enumerate(coord_grid(x0[1:], y0[0:])) ]) self.fadein(*[ Group(*[ sqs[j][i].move_to(each) for i, each in enumerate( geometrys[j].get_counting_points()) ]) for j in range(2) ]) self.fadein( *[ txty[i].move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0[0:])) ], ) self.play(AnimationGroup( Swap(*sqs[0]), CyclicReplace(*sqs[1]), ), run_time=35) self.fadeout() if 1 == 1: self.play(EndScreen01()) self.wait(5)
def construct(self): if 1 == 1: try: self.add_sound( "sidewayoutput\\basicmanim\\geometry001a_01_01_01_01_01.wav", time_offset=20) self.add_sound( "sidewayoutput\\basicmanim\\geometry001a_01_01_01_02_01.wav", time_offset=68) self.add_sound( "sidewayoutput\\basicmanim\\geometry001a_01_01_01_02_02.wav", time_offset=87) self.add_sound( "sidewayoutput\\basicmanim\\geometry001a_01_01_01_02_03.wav", time_offset=100) self.add_sound( "sidewayoutput\\basicmanim\\geometry001a_01_01_01_03_01.wav", time_offset=115) self.add_sound( "sidewayoutput\\basicmanim\\geometry001a_01_01_01_03_02.wav", time_offset=131) except: pass self.play( StartScreens01( [], [], [[r"\textbf{\textit{Basic-Manim from }\{Sideway\}}"], [r"\textbf{\textit{Geometry}}\\{{Part\ \textspA{I}a}"], [ r"\tiny{\textrm{basic-manim.210301551v0\_geometry001a}}" ], [], [ r"\scriptsize{\textbf{Warning:\ The\ content\ may\ contain\ errors,\ mistakes\ and\ inaccuracies.\ Information\ must\ be\ verified\ and\ evaluated\ before\ use.}}" ]], )) if 1 == 1: self.grow(r"\titleA{Geometry}", shift=[0, 3.6, 0]) rows, cols = (10, 6) x0, y0 = axes_point([-5.5, 2.3, cols], [3, -0.7, rows]) txty = [ "TipableVMobject()", "Arc(radius=0.5)", "ArcBetweenPoints(LO,RO)", "CurvedArrow(LO,RO)", "CurvedDoubleArrow(LO,RO)", "Circle(radius=0.5)", "Dot()", "SmallDot()", "Ellipse()", "Annulus(inner_radius=0.25,outer_radius=0.5)", "AnnularSector(inner_radius=0.25,outer_radius=0.5)", "Sector(outer_radius=0.5)", "Line()", "DashedLine()", "TangentLine(Circle(),0)", "Arrow()", "Vector()", "DoubleArrow()", "Elbow()", "CubicBezier([RO,RU/2,LU/2,LO])", "Polygon(RO,RU/2,LU/2,LO)", "RegularPolygon().scale(0.5)", "Triangle().scale_about_point(0.5,[0,0,0])", "ArrowTip()", "Rectangle().scale(0.5)", "Square().scale(0.5)", "RoundedRectangle().scale(0.5)", "TipableVMobject()", "TipableVMobject()", "TipableVMobject()" ] strs = txty self.grow( *[ GeomPoint().move_to(each) for i, each in enumerate(coord_grid(x0[:], y0[1::2])[:-3]) ], ) txty = [ "TextMobject('" + txty[i].split('(', 1)[0] + "').scale(0.55).move_to([" + ','.join(map(str, each)) + "])" for i, each in enumerate(coord_grid(x0[:], y0[0::2])) ] strs = [ strs[i] + ".shift([" + ','.join(map(str, each)) + "])" for i, each in enumerate(coord_grid(x0[:], y0[1::2])) ] strs = [j for i in zip(txty, strs) for j in i][:-6] exec("self.create(" + ','.join(strs) + ", run_time=42, lag_ratio=1)") self.fadeout() if 1 == 1: self.play( GrowFromCenter( TextMobject(r"\titleA{TipableVMobject(VMobject)}").shift( [0, 3.6, 0]).add_as_foreground(self))) rows, cols = (5, 3) x0, y0 = axes_point([1.1, 4.5, cols - 1, -4.5], [2.5, -1.2, rows]) txty = [ "TipableVMobject()", "Arc(radius = 0.5)", "ArcBetweenPoints(LO,RO)", "CurvedArrow(LO,RO)", r"\parbox{25em}{CurvedDoubleArrow(\bR{LO,RO)" ] strs = txty self.fadein(*[ TextMobject(txty[i].split('(', 1)[0]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0)) ], run_time=5) self.grow( *[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ], *[ GeomPoint().move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], ) strs = [ strs[i].replace("\\bR{", "").replace( "\\parbox{25em}{", "").replace("\\", "") + ".shift([" + ','.join(map(str, each)) + "])" for i, each in enumerate(coord_grid(x0[2:3], y0)) ] exec("self.create(" + ','.join(strs) + ", run_time=10, lag_ratio=0)") self.fadeout(exclude_mobjs="foreground") if 1 == 1: rows, cols = (7, 3) x0, y0 = axes_point([1.1, 4.5, cols - 1, -4.5], [3, -1.1, rows]) txty = [ "Circle(radius = 0.5)", "Dot()", "SmallDot()", "Ellipse()", r"\parbox{25em}{Annulus(inner\_radius = 0.25, \bR{outer\_radius = 0.5)", r"\parbox{25em}{AnnularSector(inner\_radius\bR{= 0.25, outer\_radius = 0.5)", r"Sector(outer\_radius = 0.5)" ] strs = txty self.fadein(*[ TextMobject(txty[i].split('(', 1)[0]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0)) ], run_time=5) self.grow( *[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ], *[ GeomPoint().move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], ) strs = [ strs[i].replace("\\bR{", "").replace( "\\parbox{25em}{", "").replace("\\", "") + ".shift([" + ','.join(map(str, each)) + "])" for i, each in enumerate(coord_grid(x0[2:3], y0)) ] exec("self.create(" + ','.join(strs) + ", run_time=6, lag_ratio=0)") self.fadeout(exclude_mobjs="foreground") if 1 == 1: rows, cols = (6, 3) x0, y0 = axes_point([1.1, 4.5, cols - 1, -4.5], [3, -1.1, rows]) txty = [ "Line()", "DashedLine()", "TangentLine(Circle(), 0)", "Arrow()", "Vector()", "DoubleArrow()" ] strs = txty self.fadein(*[ TextMobject(txty[i].split('(', 1)[0]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0)) ], run_time=5) self.grow( *[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ], *[ GeomPoint().move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], ) strs = [ strs[i].replace("\\bR{", "").replace( "\\parbox{25em}{", "").replace("\\", "") + ".shift([" + ','.join(map(str, each)) + "])" for i, each in enumerate(coord_grid(x0[2:3], y0)) ] exec("self.create(" + ','.join(strs) + ", run_time=5, lag_ratio=0)") self.fadeout() if 1 == 1: self.play( GrowFromCenter( TextMobject(r"\titleA{VMobject}").shift( [0, 3.6, 0]).add_as_foreground(self))) rows, cols = (3, 3) x0, y0 = axes_point([1.1, 4.5, cols - 1, -4.5], [3, -1.1, rows]) txty = [ "Elbow()", r"\parbox{25em}{CubicBezier(\bR{[RO, RU/2, LU/2, LO])", r"\parbox{25em}{Polygon(\bR{RO, RU/2, LU/2, LO)" ] strs = txty self.fadein(*[ TextMobject(txty[i].split('(', 1)[0]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0)) ], run_time=5) self.grow( *[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ], *[ GeomPoint().move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], ) strs = [ strs[i].replace("\\bR{", "").replace( "\\parbox{25em}{", "").replace("\\", "") + ".shift([" + ','.join(map(str, each)) + "])" for i, each in enumerate(coord_grid(x0[2:3], y0)) ] exec("self.create(" + ','.join(strs) + ", run_time=7, lag_ratio=0)") self.fadeout(exclude_mobjs="foreground") if 1 == 1: rows, cols = (6, 3) x0, y0 = axes_point([1.1, 4.5, cols - 1, -4.5], [3, -1.1, rows]) txty = [ "RegularPolygon().scale(0.5)", r"\parbox{25em}{Triangle().scale\_about\_point(\bR{0.5, [0, 0, 0])", "ArrowTip()", "Rectangle().scale(0.5)", "Square().scale(0.5)", r"\parbox{25em}{RoundedRectangle()\bR{.scale(0.5)" ] strs = txty self.fadein(*[ TextMobject(txty[i].split('(', 1)[0]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0)) ], run_time=5) self.grow( *[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ], *[ GeomPoint().move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], ) strs = [ strs[i].replace("\\bR{", "").replace( "\\parbox{25em}{", "").replace("\\", "") + ".shift([" + ','.join(map(str, each)) + "])" for i, each in enumerate(coord_grid(x0[2:3], y0)) ] exec("self.create(" + ','.join(strs) + ", run_time=9, lag_ratio=0)") self.fadeout() if 1 == 1: self.play(EndScreen01()) self.wait(5)
def construct(self): if 1 == 1: try: self.add_sound( "sidewayoutput\\basicmanim\\transform001a_01_01_01_01_01.wav", time_offset=18) self.add_sound( "sidewayoutput\\basicmanim\\transform001a_01_01_01_02_01.wav", time_offset=93) self.add_sound( "sidewayoutput\\basicmanim\\transform001a_01_01_01_03_01.wav", time_offset=135) except: pass self.play( StartScreens01( [], [], [[r"\textbf{\textit{Basic-Manim from }\{Sideway\}}"], [r"\textbf{\textit{Transform}}\\{{Part\ \textspA{I}a}"], [ r"\tiny{\textrm{basic-manim.210200551v0\_transform001a}}" ], [], [ r"\scriptsize{\textbf{Warning:\ The\ content\ may\ contain\ errors,\ mistakes\ and\ inaccuracies.\ Information\ must\ be\ verified\ and\ evaluated\ before\ use.}}" ]], )) if 1 == 1: self.play( GrowFromCenter( TextMobject( r"\textit{\textbf{\underline{Transform}}}").shift( [0, 3.6, 0]))) squarea = Square() squareb = Square(side_length=4).shift([4, 0, 0]) circlea = Circle() circleb = Circle(radius=2).shift([-4, 0, 0]) linea = Line([-4, 3, 0], [4, 3, 0]) lineb = Line([-3, -3, 0], [3, -3, 0]) texta = TextMobject("AB").shift([0, -2.5, 0]) textb = TextMobject("HI").shift([0, 2.5, 0]) self.play( ShowCreation(Group(squarea, circlea, squareb, circleb, linea, lineb), lag_ratio=1, run_time=12)) self.play(Write(VGroup(texta, textb), lag_ratio=1, run_time=10)) self.play(Transform(circlea, squarea, run_time=5)) self.play(Transform(circlea, squareb, path_arc=3, run_time=5)) self.play(Transform(squarea, circleb, path_arc=3, run_time=5)) self.play(Transform(linea, lineb, path_arc=3, run_time=5)) self.play(Transform(linea, circleb, path_arc=3, run_time=5)) self.play(Transform(squareb, lineb, path_arc=3, run_time=5)) self.play(Transform(texta, textb, path_arc=3, run_time=5)) self.play(Transform(texta, circleb, path_arc=3, run_time=5)) self.play(Transform(squareb, textb, path_arc=3, run_time=5)) self.fadeout() if 1 == 1: self.play( GrowFromCenter( TextMobject( r"\textit{\textbf{\underline{Paths\ of\ Transform}}}"). shift([0, 3.6, 0]))) rows, cols = (7, 5) x0, y0 = axes_point([0, 2, cols - 1, -4], [2.3, -1, rows - 1, 3]) txtx = ["loc 1", "loc 2", "m1", "m2"] txty = [ "ClockwiseTransform", "Transform", "CounterclockwiseTransform" ] a1 = Group() a2 = Group() a3 = Group() a4 = Group() for j in range(1, rows): a1.add(Circle().scale(0.2).move_to([x0[1], y0[j], 0])) a2.add(Square().scale(0.2).move_to([x0[2], y0[j], 0])) a3.add( Dot([x0[3], y0[j], 0]).add_updater(lambda mob, obj=a1[ j - 1], x=x0[3], y=y0[j]: mob.become(obj.copy( ).move_to([x, y, 0]))).suspend_updating()) a4.add( Dot([x0[4], y0[j], 0]).add_updater(lambda mob, obj=a2[ j - 1], x=x0[4], y=y0[j]: mob.become(obj.copy( ).move_to([x, y, 0]))).suspend_updating()) self.play(FadeIn( Group( *[ TextMobject(txtx[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:], y0[0:1])) ], *[ TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0[1::2])) ], *[Dot(each) for each in coord_grid(x0[1:3], y0[1:])], TextMobject(r"$\rightarrow$").move_to( ([(x0[1] + x0[2]) / 2, y0[0], 0])), a1[::2], a2[::2], a3, a4, *[ Square(stroke_width=2, color="#FFFF00", fill_opacity=0.3).add_updater( lambda mob, obj=obj: mob.surround( obj, stretch=True, buff=0.2)) for obj in a1 ], *[ Square(stroke_width=2, color="#DC75CD").add_updater( lambda mob, obj=obj: mob.surround( obj, stretch=True, buff=0.3)) for obj in a2 ])), run_time=5) self.wait(2) self.play(AnimationGroup( ClockwiseTransform(a2[0], a1[0]), ClockwiseTransform(a1[1], a2[1]), Transform(a1[2], a2[2]), Transform(a2[3], a1[3]), CounterclockwiseTransform(a1[4], a2[4]), CounterclockwiseTransform(a2[5], a1[5]), ), run_time=25) self.wait(3) a1.shift([0.3, 0, 0]).set_color("#11FF00") self.wait(3) self.play(ApplyMethod(a1.shift, ([0.3, 0, 0])), run_time=3) self.fadeout() if 1 == 1: self.play( GrowFromCenter( TextMobject( r"\textit{\textbf{\underline{Methods\ of\ Transform}}}" ).shift([0, 3.6, 0]))) rows, cols = (9, 5) x0, y0 = axes_point([0, 2, cols - 1, -4], [2.3, -0.8, rows - 1, 3]) txtx = ["loc 1", "loc 2", "m1", "m2"] txty = [ "Transform", "ReplacementTransform", "TransformFromCopy", "MoveToTarget" ] a1 = Group() a2 = Group() a3 = Group() a4 = Group() for j in range(1, rows): a1.add(Circle().scale(0.2).move_to([x0[1], y0[j], 0])) a2.add(Square().scale(0.2).move_to([x0[2], y0[j], 0])) a3.add(Dot().move_to([x0[3], y0[j], 0]).add_updater( lambda mob, obj=a1[j - 1], x=x0[3], y=y0[j]: mob.become( obj.copy().move_to([x, y, 0]))).suspend_updating()) a4.add(Dot().move_to([x0[4], y0[j], 0]).add_updater( lambda mob, obj=a2[j - 1], x=x0[4], y=y0[j]: mob.become( obj.copy().move_to([x, y, 0]))).suspend_updating()) a1[6].target = a2[6] a1[7].target = a2[7] self.play(FadeIn( Group( *[ TextMobject(txtx[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:], y0[0:1])) ], *[ TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0[1::2])) ], *[Dot(each) for each in coord_grid(x0[1:3], y0[1:])], TextMobject(r"$\rightarrow$").move_to( ([(x0[1] + x0[2]) / 2, y0[0], 0])), a1[::2], a2[::2], a3, a4, Group(*[ Square( stroke_width=2, color="#FFFF00", fill_opacity=0.3). add_updater(lambda mob, obj=obj: mob.surround( obj, stretch=True, buff=0.2)) for obj in a1 ]), Group(*[ Square(stroke_width=2, color="#DC75CD").add_updater( lambda mob, obj=obj: mob.surround( obj, stretch=True, buff=0.3)) for obj in a2 ]))), run_time=5) self.wait(2) self.play(AnimationGroup(Transform(a1[0], a2[0]), Transform(a1[1], a2[1]), ReplacementTransform(a1[2], a2[2]), ReplacementTransform(a1[3], a2[3]), TransformFromCopy(a1[4], a2[4]), TransformFromCopy(a1[5], a2[5]), MoveToTarget(a1[6]), MoveToTarget(a1[7])), run_time=40) self.wait(3) a1.shift([0.3, 0, 0]).set_color("#11FF00") self.wait(10) self.play(ApplyMethod(a1.shift, ([0.3, 0, 0])), run_time=5) self.fadeout() if 1 == 1: self.play(EndScreen01()) self.wait(5)
def construct(self): if 1 == 1: try: self.add_sound( "sidewayoutput\\basicmanim\\growing001a_01_01_01_01_01.wav", time_offset=19) self.add_sound( "sidewayoutput\\basicmanim\\growing001a_01_01_01_02_01.wav", time_offset=43) self.add_sound( "sidewayoutput\\basicmanim\\growing001a_01_01_01_03_01.wav", time_offset=89) self.add_sound( "sidewayoutput\\basicmanim\\growing001a_01_01_01_04_01.wav", time_offset=136) self.add_sound( "sidewayoutput\\basicmanim\\growing001a_01_01_01_05_01.wav", time_offset=180) except: pass self.play( StartScreens01( [], [], [[r"\textbf{\textit{Basic-Manim from }\{Sideway\}}"], [r"\textbf{\textit{Growing}}\\{{Part\ \textspA{I}a}"], [r"\tiny{\textrm{basic-manim.210300151v0\_growing001a}}"], [], [ r"\scriptsize{\textbf{Warning:\ The\ content\ may\ contain\ errors,\ mistakes\ and\ inaccuracies.\ Information\ must\ be\ verified\ and\ evaluated\ before\ use.}}" ]], )) if 1 == 1: self.grow(r"\titleA{Growing}", shift=[0, 3.6, 0]) rows, cols = (4, 3) x0, y0 = axes_point([1, 4, cols - 1, -4.5], [2.5, -1.9, rows]) txty = ["Growing", " Diminishing", "One Direction", "Spin"] strs = [ each + "(sqs[" + str(i) + "])" for i, each in enumerate([ "GrowFromCenter", "DiminishToCenter", "GrowArrow", "SpinInFromNothing" ]) ] sqs = [GeomSquare(1.2) for i in range(rows)] self.fadein(*[ TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0)) ], *[ Group(GeomPoint(), TextMobject("sqs[" + str(i) + "]"), sqs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], run_time=5) self.grow(*[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ]) exec("self.play(" + ','.join(strs) + "," + "run_time=15)") self.fadeout() if 1 == 1: self.grow(r"\titleA{GrowFrom}", shift=[0, 3.6, 0]) rows, cols = (4, 3) x0, y0 = axes_point([1, 4, cols - 1, -4.5], [2.5, -1.9, rows]) txty = [ "GrowFromPoint", "GrowFromCenter", "GrowFromEdge", "GrowFromSide" ] strs = [ txty[i] + "(sqs[" + str(i) + "]" + each + ")" for i, each in enumerate([",UP", "", ",UP", ",UP"]) ] sqs = [GeomSquare(1.2) for i in range(rows)] self.fadein(*[ TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0)) ], *[ Group(GeomPoint(), TextMobject("sqs[" + str(i) + "]"), sqs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], run_time=5) self.grow(*[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ]) exec("self.play(" + ','.join(strs) + "," + "run_time=35)") self.fadeout() if 1 == 1: self.grow(r"\titleA{DiminishTo}", shift=[0, 3.6, 0]) rows, cols = (4, 3) x0, y0 = axes_point([1, 4, cols - 1, -4.5], [2.5, -1.9, rows]) txty = [ "DiminishToPoint", "DiminishToCenter", "DiminishToEdge", "DiminishToSide" ] strs = [ txty[i] + "(sqs[" + str(i) + "]" + each + ")" for i, each in enumerate([",UP", "", ",UP", ",UP"]) ] sqs = [GeomSquare(1.2) for i in range(rows)] self.fadein(*[ TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0)) ], *[ Group(GeomPoint(), TextMobject("sqs[" + str(i) + "]"), sqs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], run_time=5) self.grow(*[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ]) exec("self.play(" + ','.join(strs) + "," + "run_time=38)") self.fadeout() if 1 == 1: self.grow(r"\titleA{One Direction}", shift=[0, 3.6, 0]) rows, cols = (8, 3) x0, y0 = axes_point([1, 4, cols - 1, -4.5], [2.8, -0.9, rows]) txty = to_get_zlist( ["GrowArrow", "ExpandArrow", "DiminishArrow", "RetractArrow"], n=2) strs = [txty[i] + "(sqs[" + str(i) + "])" for i in range(rows)] sqs = to_get_zlist([GeomRectangle(0.6, 1.2), GeomArrow()], n=(4, )) self.fadein(*[ TextMobject(txty[i * 2]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0[:-1:2])) ], *[ Group(GeomPoint(), TextMobject("sqs[" + str(i) + "]"), sqs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], run_time=5) self.fadein(*[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ]) exec("self.play(" + ','.join(strs) + "," + "run_time=35)") self.fadeout() if 1 == 1: self.grow(r"\titleA{Spin}", shift=[0, 3.6, 0]) rows, cols = (5, 3) x0, y0 = axes_point([1.8, 4, cols - 1, -4.2], [3, -1.5, rows]) txty = [ "SpinInFromNothing", "SpinInFrom", "SpinOutFrom", "SpinInTo", "SpinOutTo" ] strs = [ txty[i] + "(sqs[" + str(i) + "]" + each + ")" for i, each in enumerate(["", "", "", "", ""]) ] sqs = [ GeomRegularPolygon(5, ORIGIN, 0.8).add( GeomArrow([0, 0.07, 0], [0, 0.8, 0])) for i in range(rows) ] self.fadein(*[ TextMobject(txty[i]).move_to(each) for i, each in enumerate(coord_grid(x0[0:1], y0)) ], *[ Group(GeomPoint(), TextMobject("sqs[" + str(i) + "]"), sqs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[2:3], y0)) ], run_time=5) self.grow(*[ TextMobject(strs[i]).move_to(each) for i, each in enumerate(coord_grid(x0[1:2], y0)) ]) exec("self.play(" + ','.join(strs) + "," + "run_time=50)") self.fadeout() if 1 == 1: self.play(EndScreen01()) self.wait(5)