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.
Pair of squares morphing into circles simultaneously.
scene = Scene(fps=60, width=960, height=540)m1a = Square().set_color(RED).shift(LEFT)m1b = Circle().set_color(RED).shift(LEFT)m2a = Square().set_color(BLUE).shift(RIGHT)m2b = Circle().set_color(BLUE).shift(RIGHT)scene.play(Transform(m1a, m1b), Transform(m2a, m2b), run_time=1.2)scene.wait(0.8)
Square to Rectangle with rotation.
scene = Scene(fps=30, width=640, height=360)m1 = Square().set_color(RED)m2 = Rectangle(width=3, height=2).set_color(RED).rotate(0.2)scene.add(m1, m2)scene.play(Transform(m1, m2), run_time=1.5)scene.wait(1)
Morph an equilateral triangle into a square.
scene = Scene(fps=60, width=960, height=540)tri = Triangle().set_color(ORANGE).shift(LEFT*1.5)sqr = Square().set_color(ORANGE).shift(LEFT*1.5)scene.add(tri)scene.play(Transform(tri, sqr), run_time=1.2)scene.wait(0.8)
Wide rectangle easing into a circle.
scene = Scene(fps=60, width=960, height=540)rect = Rectangle(width=4, height=2).set_color(TEAL).shift(RIGHT*1.5)circ = Circle().set_color(TEAL).shift(RIGHT*1.5)scene.add(rect)scene.play(Transform(rect, circ), run_time=1.2)scene.wait(0.8)
Compares normal and rolled point-order transforms in parallel.
class ExampleRotation(Scene): def construct(self): m1a = Square().set_color(RED).shift(LEFT) m1b = Circle().set_color(RED).shift(LEFT) m2a = Square().set_color(BLUE).shift(RIGHT) m2b = Circle().set_color(BLUE).shift(RIGHT) points = m2a.points points = np.roll(points, int(len(points) / 4), axis=0) m2a.points = points self.play(Transform(m1a, m1b), Transform(m2a, m2b), run_time=1) scene = ExampleRotation()scene.construct()