Core Objects
- - Circle, Square, Rectangle, Line, Arrow, Dot, Polygon, RegularPolygon
- - Text, Tex, MathTex
- - ImageMobject, SVGMobject
- - Group and VGroup
Runnable examples for the currently supported feature set. Previews are lazy and only compile when you click Render preview, so opening this page does not trigger a flood of compile requests.
Animate a dot around a circular guide path while leaving the guide visible.
scene = Scene(fps=30, width=960, height=540, backgroundColor="#020617") orbit = Circle(radius=2.2, color=GREY_C)planet = Dot(color=YELLOW).move_to(orbit.point_from_proportion(0))sun = Dot(color=ORANGE).scale(1.8)title = Text("MoveAlongPath", font_size=34, color=WHITE).to_edge(UP) scene.add(orbit, sun, planet, title)scene.play(MoveAlongPath(planet, orbit), run_time=3.2, rate_func=linear)scene.wait(0.4)
Three dots traverse the same distance with linear, smooth, and there_and_back timing.
scene = Scene(fps=30, width=960, height=540, backgroundColor="#020617") base = Line(LEFT * 4, RIGHT * 4, color=GREY_D)labels = VGroup( Text("linear", font_size=22, color=BLUE), Text("smooth", font_size=22, color=GREEN), Text("there_and_back", font_size=22, color=YELLOW),).arrange(DOWN, aligned_edge=LEFT, buff=0.9).move_to(LEFT * 4.8) dots = VGroup( Dot(color=BLUE).move_to(LEFT * 4 + UP * 1.2), Dot(color=GREEN).move_to(LEFT * 4), Dot(color=YELLOW).move_to(LEFT * 4 + DOWN * 1.2),) scene.add( base.copy().shift(UP * 1.2), base, base.copy().shift(DOWN * 1.2), labels, dots,)scene.play(dots[0].animate.move_to(RIGHT * 4 + UP * 1.2), run_time=2.4, rate_func=linear)scene.play(dots[1].animate.move_to(RIGHT * 4), run_time=2.4, rate_func=smooth)scene.play(dots[2].animate.move_to(RIGHT * 4 + DOWN * 1.2), run_time=2.4, rate_func=there_and_back)scene.wait(0.4)
Move, rotate, and scale a VGroup so its 2D children behave like one object.
scene = Scene(width=960, height=540, backgroundColor="#0f172a") hub = Circle(radius=0.42, color=BLUE, fill_opacity=0.2)sat_a = Square(side_length=0.46, color=GREEN).move_to(LEFT * 1.1 + UP * 0.35)sat_b = Triangle(color=YELLOW).scale(0.38).move_to(RIGHT * 1.0 + UP * 0.2)sat_c = Dot(color=ORANGE).scale(1.5).move_to(DOWN * 0.95) connector_a = Line(hub.get_center(), sat_a.get_center(), color=GREY_B)connector_b = Line(hub.get_center(), sat_b.get_center(), color=GREY_B)connector_c = Line(hub.get_center(), sat_c.get_center(), color=GREY_B)label = Text("VGroup", font_size=20, color=WHITE).move_to(hub.get_center()) cluster = VGroup(connector_a, connector_b, connector_c, hub, sat_a, sat_b, sat_c, label)cluster.move_to(LEFT * 3.0 + DOWN * 0.2) title = Text("Grouped 2D transforms", font_size=30, color=WHITE).to_edge(UP, buff=0.35)target = DashedLine(LEFT * 0.4 + DOWN * 1.6, RIGHT * 3.7 + DOWN * 1.6, color=GREY_D)caption = Text("shift -> Rotate -> scale + move_to", font_size=22, color=GREY_B).next_to(target, DOWN, buff=0.24) scene.add(title, target, caption, cluster)scene.play(cluster.animate.shift(RIGHT * 2.5), run_time=0.9)scene.play(Rotate(cluster, PI / 3), run_time=1.0)scene.play(cluster.animate.scale(0.82).move_to(RIGHT * 2.7 + DOWN * 0.2), run_time=1.0)scene.wait(0.4)