vertical_line = Line(rightest * RIGHT, rightest * RIGHT + highest * UP, color=GREEN) horizontal_line = Line(highest * UP, highest * UP + rightest * RIGHT, color=GREEN) self.bring_to_back(vertical_line, horizontal_line) azimuth_arc = Arc(0, self.azimuth) self.add(azimuth_arc) self.wait() def get_ellipse_rightest_point(self, a, b, theta): angle = math.atan(b / a * math.tan(theta)) return a * math.cos(angle) * math.cos(theta) + b * math.sin( angle) * math.sin(theta) def get_ellipse_highest_point(self, a, b, theta): angle = math.atan(b / (a * math.tan(theta))) return a * math.cos(angle) * math.sin(theta) + b * math.sin( angle) * math.cos(theta) if __name__ == '__main__': from customutils2.manimutils.make_scene import make_scene make_scene(PolarizationEllipse, color="grey")
def lower_func(self, x): return self.upper_func(x) + self.middle_func(x) def anim_pi_2(self, _, alpha): self.anim_func(_, alpha, 0, np.pi / 2) def anim_pi_3(self, _, alpha): self.anim_func(_, alpha, np.pi / 2, np.pi / 3) def anim_pi_something(self, _, alpha): self.anim_func(_, alpha, np.pi / 3, 10 * np.pi / 13) def anim_func(self, _, alpha, from_phase, to_phase): self.phase = interpolate(from_phase, to_phase, alpha) new_middle = self.make_graph(self.middle_func, MIDDLE_COLOR).shift(MIDDLE_POSITION) new_lower = self.make_graph(self.lower_func, LOWER_COLOR).shift(LOWER_POSITION) self.middle_graph.become(new_middle) self.lower_graph.become(new_lower) if __name__ == '__main__': make_scene( Superposition, color="white", quality=MEDIUM_QUALITY, frame_rate=24, # stop_at_animation_number=5, )
Write(words), GrowArrow(arrow), MaintainPositionRelativeTo( frame, point_mob) ]) self.wait(2) def write_derivative(self): pass # Helpers def get_plane(self): top_plane = NumberPlane( y_radius=FRAME_HEIGHT / 2, x_line_frequency=0.1, y_line_frequency=0.1, ) self.prepare_for_transformation(top_plane) bottom_plane = top_plane.copy() tiny_tiny_buff = 0.001 top_plane.next_to(ORIGIN, UP, buff=tiny_tiny_buff) bottom_plane.next_to(ORIGIN, DOWN, buff=tiny_tiny_buff) return VGroup(top_plane, bottom_plane) if __name__ == '__main__': ROOT_PATH = r"C:\Users\tomas\Repositories\manimPlayground" make_scene(AnalyzeZSquared, video_dir=os.path.join(ROOT_PATH, "video"), tex_dir=os.path.join(ROOT_PATH, "tex"))
self.play(Write(text, rate_func=lambda t: smooth(1 - t))) self.wait() class LaggedStartMapHowTo(Scene): def construct(self): # construction of demo props lines = VGroup() for i in range(-5, 6): lines.add(Line(3 * UP + i * RIGHT, 3 * DOWN + i * RIGHT)) # LaggedStartMap is used when you want to apply one animation to lots of mobjects # with lagged start # run_time is for the whole LaggedStartMap animation, not for individual animations # lag_ratio - how much does it wait before running next animation (as a ratio of the time # of one animation) # rate_func applies for individual animations, launching the animations is always linear, # because lag_ratio is constant self.play( LaggedStartMap(ShowCreation, lines, run_time=10, lag_ratio=0.5, rate_func=linear)) self.wait() if __name__ == '__main__': make_scene(PlayAnimationsBackwards)
from manimlib.constants import * from manimlib.mobject.geometry import Circle, Square, Line, Dot, Arrow, Triangle from manimlib.mobject.svg.svg_mobject import SVGMobject from manimlib.mobject.svg.tex_mobject import TexMobject, TextMobject from manimlib.mobject.types.vectorized_mobject import VMobject, VGroup from manimlib.scene.scene import Scene from manimlib.utils.rate_functions import linear class Waiting(Scene): def construct(self): self.wait() class TestingPointFromProportion(Scene): def construct(self): obj = SVGMobject("dvsv").scale(3) points = VGroup(*[ Dot(obj.point_from_proportion(alpha)) for alpha in np.linspace(0, 1, 33) ]) self.add(obj) self.add(points) self.wait() if __name__ == '__main__': make_scene(TestingPointFromProportion)
# if i%3 == 1: # new_str += "{,}" if i % (n_chars / 4) == 0: new_str += " \\\\ " background_num = TexMobject(new_str) background_num.set_width(FRAME_WIDTH - LARGE_BUFF) background_num.set_fill(opacity=0.2) secure = TextMobject("Secure?") secure.scale(4) secure.shift(FRAME_Y_RADIUS * DOWN / 2) secure.set_color(RED) secure.set_stroke(RED_A, 3) lock = SVGMobject( file_name="example", fill_color=WHITE, ) lock.set_height(6) self.add(background_num, num) self.wait() if __name__ == '__main__': make_scene( MainBreakdown, video_dir="../../video", tex_dir="../../tex", )
if not len(self.ellipse.get_points()): self.ellipse.set_points([UP * y + RIGHT * x]) else: self.ellipse.add_points_as_corners([UP * y + RIGHT * x]) def do_vectors_only_period_hide(self, _, alpha): fade_ratio = 3 if alpha >= (fade_ratio - 1) / fade_ratio: opacity = 1 - smooth(fade_ratio * alpha - (fade_ratio - 1)) self.x_vector.set_opacity(opacity) self.y_vector.set_opacity(opacity) self.xy_vector.set_opacity(opacity) self.ellipse.set_stroke(opacity=opacity) self.do_vectors_only_period(_, alpha) def comp_point(self, alpha): point_x = self.vector_length * np.cos( 2 * np.pi * alpha) * RIGHT + 0.01 * RIGHT point_y = self.vector_length * np.cos(2 * np.pi * alpha + self.phase) * UP + 0.01 * UP return point_x, point_y if __name__ == '__main__': make_scene( Polarization, quality=HIGH_QUALITY, frame_rate=24, save_as_gif=True, )
circle.to_edge(RIGHT, buff=1) self.play(ShowCreation(circle)) for x, y in [(2, 100), (3, 60), (4, 60), (5, 70)]: self.Example3b1b(self.get_m_mod_n_objects(x, y), x, y) self.play(FadeOut(circle)) def Example3b1b(self, obj, x, y): circle, lines = obj lines.set_stroke(width=1) label = TexMobject(f"f({x},{y})").scale(2.5).to_edge(LEFT, buff=1) VGroup(circle, lines).to_edge(RIGHT, buff=1) self.play(Write(label), self.LaggedStartLines(lines)) self.wait() lines_c = lines.copy() lines_c.set_color(PINK) lines_c.set_stroke(width=3) self.play(self.LaggedStartShowCrationThenDestructionLines(lines_c)) self.wait() self.play(FadeOut(lines), Write(label, rate_func=lambda t: smooth(1 - t))) def LaggedStartLines(self, lines): return LaggedStartMap(ShowCreation, lines, run_time=4) def LaggedStartShowCrationThenDestructionLines(self, lines): return LaggedStartMap(ShowCreationThenDestruction, lines, run_time=6) if __name__ == '__main__': make_scene(MmodN, quality=MEDIUM_QUALITY)
"Kaustuv DeBiswas", "Lambda AI Hardware", "Lukas Biewald", "Mark Heising", "Mike Coleman", "Nicholas Cahill", "Peter Mcinerney", "Quantopian", "Roy Larson", "Scott Walter, Ph.D.", "Yana Chernobilsky", "Yu Jun", "D. Sivakumar", "Richard Barthel", "Burt Humburg", "Matt Russell", "Scott Gray", "soekul", "Tihan Seale", "Juan Benet", "Vassili Philippov", "Kurt Dicus", ], } if __name__ == '__main__': ROOT_PATH = r"C:\Users\tomas\Repositories\manimPlayground" make_scene(EndScreen, video_dir=os.path.join(ROOT_PATH, "video"), tex_dir=os.path.join(ROOT_PATH, "tex"))
"thinking", "thinking", "thinking", look_at_arg=4 * LEFT + 2 * UP ) self.wait(2) class ReferenceKhanVideo(TeacherStudentsScene): def construct(self): khan_logo = ImageMobject("KhanLogo") khan_logo.set_height(1) khan_logo.next_to(self.teacher, UP, buff=2) khan_logo.shift(2 * LEFT) self.play( self.teacher.change, "raise_right_hand", ) self.change_student_modes( "thinking", "pondering", "thinking", look_at_arg=self.screen ) self.wait() self.play(FadeInFromDown(khan_logo)) self.look_at(self.screen) self.wait(15) if __name__ == '__main__': ROOT_PATH = r"C:\Users\tomas\Repositories\manimPlayground" make_scene(AskAboutWhereEquationComesFrom, video_dir=os.path.join(ROOT_PATH, "video"), tex_dir=os.path.join(ROOT_PATH, "tex"))
} def get_object(self): height = 2 prism = VGroup() triangle = RegularPolygon(3) verts = triangle.get_anchors()[:3] rects = [ Polygon(v1, v2, v2 + height * OUT, v1 + height * OUT) for v1, v2 in adjacent_pairs(verts) ] prism.add(triangle, *rects) prism.add(triangle.copy().shift(height * OUT)) triangle.reverse_points() prism.set_shade_in_3d(True) prism.set_fill(PINK, 0.8) prism.set_stroke(WHITE, 1) return prism class TheseFourPiAreSquare(PiCreatureScene): def construct(self): pass def create_pi_creatures(self): pass if __name__ == '__main__': make_scene(CylinderShadows, video_dir="../../video", tex_dir="../../tex")
FadeIn(headphones), morty.change_mode, "thinking", FadeOut(morty.bubble), FadeOut(morty.bubble.content), ) self.play(Write(url)) self.play(morty.change_mode, "happy") self.wait(2) self.play(Blink(morty)) self.wait(2) self.play(morty.change_mode, "raise_right_hand", morty.look_at, url) self.wait(2) self.play(morty.change_mode, "happy", morty.look_at, book) self.play(FadeIn(book)) self.play(ShowCreation(border)) self.wait(2) self.play(Blink(morty)) self.wait() self.play(morty.change_mode, "thinking", morty.look_at, book) self.wait(2) self.play(Blink(morty)) self.wait(4) self.play(Blink(morty)) if __name__ == '__main__': make_scene(ExplainTrigFunctionDistances, video_dir="../../video", tex_dir="../../tex")
from customutils2.manimutils.make_scene import make_scene from manimlib.animation.creation import ShowCreation from manimlib.mobject.coordinate_systems import ThreeDAxes from manimlib.mobject.geometry import Circle from manimlib.scene.three_d_scene import ThreeDScene from manimlib.constants import * class CameraPosition1(ThreeDScene): def construct(self): axes = ThreeDAxes() circle = Circle() self.set_camera_orientation(phi=0 * DEGREES) self.play(ShowCreation(circle), ShowCreation(axes)) self.wait() if __name__ == '__main__': make_scene(CameraPosition1)
from manimlib.animation.creation import ShowCreation from manimlib.mobject.geometry import Circle from manimlib.mobject.svg.tex_mobject import TexMobject from manimlib.scene.scene import Scene class Test(Scene): def construct(self): circle = Circle() text = TexMobject(r"\pi") self.play(ShowCreation(circle)) self.play(circle.become, text) self.wait() if __name__ == '__main__': from customutils2.manimutils.make_scene import make_scene make_scene(Test)
class SuccessionExample3(Scene): def construct(self): number_line = NumberLine(x_min=-2, x_max=2) text_1 = TextMobject("Theorem of") \ .next_to(number_line, DOWN) text_2 = TextMobject("Beethoven") \ .next_to(number_line, DOWN) dashed_line = DashedLine( number_line.get_left(), number_line.get_right(), color=YELLOW, ).set_stroke(width=11) self.add(number_line, text_1) self.play( LaggedStart(*[ ShowCreationThenDestruction(dashed_segment) for dashed_segment in dashed_line ], run_time=5), AnimationGroup(Animation(Mobject(), run_time=2.1), ReplacementTransform(text_1, text_2), lag_ratio=1)) self.wait() if __name__ == '__main__': make_scene(SuccessionExample3)
"height": 2, }, } def construct(self): self.setup_input_space() self.setup_input_trackers() self.play( self.input_tracker.set_value, 1, run_time=10, rate_func=linear ) def get_input_line(self, rect): result = ClarifyInputAndOutput.get_input_line(self, rect) result.stretch(0.9, 0) result.set_stroke(width=2) for sm in result.get_family(): if isinstance(sm, DecimalNumber): sm.stretch(1 / 0.9, 0) sm.set_stroke(width=0) return result if __name__ == '__main__': ROOT_PATH = r"C:\Users\tomas\Repositories\manimPlayground" make_scene(TRangingFrom0To1, video_dir=os.path.join(ROOT_PATH, "video"), tex_dir=os.path.join(ROOT_PATH, "tex"))
c, f_d, d_d, d = group d.move_to(self.coords_to_point(dot_guide.get_center()[0], 0)) radius = get_norm(focus.get_center() - dot_guide.get_center()) new_c = Circle(radius=radius) new_c.move_to(dot_guide) c.become(new_c) f_d.become(DashedLine(focus.get_center(), dot_guide.get_center())) d_d.become(DashedLine(dot_guide.get_center(), dot_d.get_center())) group.add_updater(update_group) self.play(*[ GrowFromCenter(mob) for mob in [circle, line_f_d, line_d_d, dot_guide, dot_d, focus] ]) self.add( group, focus, dot_guide, ) self.wait() self.play(ShowCreation(parabola), MoveAlongPath(dot_guide, parabola_copy), **anim_kwargs) group.clear_updaters() self.wait(1.2) self.play(FadeOut(VGroup(group, dot_guide, focus))) if __name__ == '__main__': make_scene(ParabolaCreation)
} def construct(self): circle = Circle(color=YELLOW).scale(self.radius) points = [] lines = [] for point in range(self.points): start_angle = (point / self.points) * 2 * np.pi start_point = (RIGHT * np.cos(start_angle) + UP * np.sin(start_angle)) * self.radius points.append(start_point) stop_angle = (point + point * self.step) / self.points * 2 * np.pi stop_point = (RIGHT * np.cos(stop_angle) + UP * np.sin(stop_angle)) * self.radius lines.append(Line(start_point, stop_point, **self.line_config)) self.play(ShowCreation(circle)) self.wait() points_group = VGroup(*[Dot(point, **self.dot_config) for point in points]) lines_group = VGroup(*lines) # self.play(ShowCreation(points_group), run_time=2) self.play(ShowCreation(lines_group), run_time=10, rate_func=linear) self.wait() if __name__ == '__main__': make_scene(Cardioid, quality=MEDIUM_QUALITY)
"RedAgent14", "rehmi post", "Richard Burgmann", "Richard Comish", "Ripta Pasay", "Rish Kundalia", "Robert Teed", "Roobie", "Ryan Williams", "Sachit Nagpal", "Solara570", "Stevie Metke", "Tal Einav", "Ted Suzman", "Thomas Tarler", "Tom Fleming", "Valeriy Skobelev", "Xavier Bernard", "Yavor Ivanov", "Yaw Etse", "YinYangBalance.Asia", "Zach Cardwell", ], } if __name__ == '__main__': ROOT_PATH = r"C:\Users\tomas\Repositories\manimPlayground" make_scene(WriteHeatEquationTemplate, video_dir=os.path.join(ROOT_PATH, "video"), tex_dir=os.path.join(ROOT_PATH, "tex"))
def construct(self): self.add_axes() self.add_score_label() self.setup_histogram() self.show_many_runs() def add_axes(self): axes = Axes(**self.axes_config) def add_score_label(self): pass def setup_histogram(self): pass def show_many_runs(self): pass # def add_one_run(self, animate=True): pass def get_random_score(self): pass if __name__ == '__main__': from customutils2.manimutils.make_scene import make_scene make_scene(ShowUniformDistribution)
self.always_continually_update = True self.wait(10) def continual_update(self, *args, **kwargs): if hasattr(self, "moving_particles"): dt = self.frame_duration for p in self.moving_particles: accel = self.field_at_point(p.get_center()) p.velocity = p.velocity + accel * dt p.shift(p.velocity * dt) class Positron(Circle): CONFIG = { "radius": 0.2, "stroke_width": 3, "color": RED, "fill_color": RED, "fill_opacity": 0.5, } def __init__(self, **kwargs): Circle.__init__(self, **kwargs) plus = TexMobject("+") plus.scale(0.7) plus.move_to(self) self.add(plus) if __name__ == '__main__': make_scene(MovingCharges, video_dir="../video", tex_dir="../tex")
from manimlib.animation.update import UpdateFromAlphaFunc from manimlib.mobject.geometry import Circle, Square from manimlib.mobject.types.vectorized_mobject import VMobject from manimlib.scene.scene import Scene from manimlib.constants import * from manimlib.utils.rate_functions import linear class AlphaTest(Scene): def construct(self): circle = Circle() square = Square() self.add(circle) self.add(square) self.play(UpdateFromAlphaFunc(circle, self.update_stuff), UpdateFromAlphaFunc(square, self.update_stuff, rate_func=linear)) self.wait() def update_stuff(self, mobject: VMobject, alpha): mobject.move_to(alpha * (UP + LEFT)) if __name__ == '__main__': make_scene(AlphaTest, video_dir="../video", tex_dir="../tex")
self.slow_factor_tracker.set_value(0.1) self.wait(20) # def configure_path(self, path): path.set_stroke(WHITE, 1) path.set_fill(BLACK, opacity=1) path.set_height(self.path_height) path.move_to(self.center_point) return path def get_path(self): tex = TexMobject("f") path = tex.family_members_with_points()[0] self.configure_path(path) return path # return Square().set_height(3) def get_new_path(self): shape = SVGMobject("TrebleClef") path = shape.family_members_with_points()[0] self.configure_path(path) path.scale(1.5, about_edge=DOWN) return path if __name__ == '__main__': ROOT_PATH = r"C:\Users\tomas\Repositories\manimPlayground" make_scene(ExplainCircleAnimations, video_dir=os.path.join(ROOT_PATH, "video"), tex_dir=os.path.join(ROOT_PATH, "tex"))
Group(equation, image).shift(1.5 * RIGHT) question = TextMobject("What is\\\\this?") question.scale(2.5) question.to_edge(LEFT) arrow = Arrow( question.get_top(), equation.get_left(), buff=0.5, path_arc=-90 * DEGREES, ) arrow.set_stroke(width=5) self.add(question, arrow) class ShowNewton(Scene): def construct(self): pass class ShowCupOfWater(Scene): def construct(self): pass if __name__ == '__main__': ROOT_PATH = r"C:\Users\tomas\Repositories\manimPlayground" make_scene(ShowCupOfWater, video_dir=os.path.join(ROOT_PATH, "video"), tex_dir=os.path.join(ROOT_PATH, "tex"))
pass def show_n2_factors(self): pass def show_n2_factor_sum(self): pass # def show_factors(self, dot_group): pass def get_all_factor_rectangles(self, dot_group): n = len(dot_group) factors = get_factors(n) colors = it.cycle(self.colors) result = VGroup() for k, color in zip(factors, colors): group = dot_group.copy() group.set_color(color) group.arrange_in_grid(n_rows=k, buff=SMALL_BUFF) group.first_col = group[::(n // k)] result.add(group) return result if __name__ == '__main__': ROOT_PATH = r"C:\Users\tomas\Repositories\manimPlayground" make_scene(AmicableNumbers, video_dir=os.path.join(ROOT_PATH, "video"), tex_dir=os.path.join(ROOT_PATH, "tex"))