{ "cells": [ { "cell_type": "markdown", "id": "radical-triumph", "metadata": {}, "source": [ "**Note:** This is a temporary test environment in which you can play around with Manim without the need of installing it locally. Keep in mind that this is a *temporary* environment, though: your changes will not be saved and cannot be shared with others. To save your work, you will need to download the notebook file (\"File > Download as > Notebook (.ipynb)\"). Enjoy!\n", "\n", "*Useful resources:* [Documentation](https://docs.manim.community), [Discord](https://discord.gg/mMRrZQW), [Reddit](https://www.reddit.com/r/manim/)" ] }, { "cell_type": "code", "execution_count": null, "id": "needed-keeping", "metadata": {}, "outputs": [], "source": [ "from manim import *" ] }, { "cell_type": "code", "execution_count": null, "id": "variable-concentration", "metadata": {}, "outputs": [], "source": [ "%manim --help" ] }, { "cell_type": "code", "execution_count": null, "id": "exclusive-superior", "metadata": {}, "outputs": [], "source": [ "%%manim -qm -v WARNING SquareToCircle\n", "\n", "class SquareToCircle(Scene):\n", " def construct(self):\n", " circle = Circle()\n", " square = Square()\n", " square.flip(RIGHT)\n", " square.rotate(-3 * TAU / 8)\n", " circle.set_fill(PINK, opacity=0.5)\n", "\n", " self.play(Create(square))\n", " self.play(Transform(square, circle))\n", " self.play(FadeOut(square))" ] }, { "cell_type": "code", "execution_count": null, "id": "norwegian-sherman", "metadata": {}, "outputs": [], "source": [ "%%manim -qm -v WARNING WarpSquare\n", "\n", "class WarpSquare(Scene):\n", " def construct(self):\n", " square = Square()\n", " self.play(\n", " ApplyPointwiseFunction(\n", " lambda point: complex_to_R3(np.exp(R3_to_complex(point))), square\n", " )\n", " )\n", " self.wait()" ] }, { "cell_type": "code", "execution_count": null, "id": "individual-excellence", "metadata": {}, "outputs": [], "source": [ "%%manim -qm -v WARNING WriteStuff\n", "\n", "class WriteStuff(Scene):\n", " def construct(self):\n", " example_text = Tex(\"This is some text\", tex_to_color_map={\"text\": YELLOW})\n", " example_tex = MathTex(\n", " \"\\\\sum_{k=1}^\\\\infty {1 \\\\over k^2} = {\\\\pi^2 \\\\over 6}\",\n", " )\n", " group = VGroup(example_text, example_tex)\n", " group.arrange(DOWN)\n", " group.set(width=config[\"frame_width\"] - 2 * LARGE_BUFF)\n", "\n", " self.play(Write(example_text))\n", " self.play(Write(example_tex))\n", " self.wait()" ] }, { "cell_type": "code", "execution_count": null, "id": "iraqi-creation", "metadata": {}, "outputs": [], "source": [ "%%manim -qm -v WARNING UpdatersExample\n", "\n", "class UpdatersExample(Scene):\n", " def construct(self):\n", " decimal = DecimalNumber(\n", " 0,\n", " show_ellipsis=True,\n", " num_decimal_places=3,\n", " include_sign=True,\n", " )\n", " square = Square().to_edge(UP)\n", "\n", " decimal.add_updater(lambda d: d.next_to(square, RIGHT))\n", " decimal.add_updater(lambda d: d.set_value(square.get_center()[1]))\n", " self.add(square, decimal)\n", " self.play(\n", " square.animate.to_edge(DOWN),\n", " rate_func=there_and_back,\n", " run_time=5,\n", " )\n", " self.wait()" ] }, { "cell_type": "code", "execution_count": null, "id": "hearing-adjustment", "metadata": {}, "outputs": [], "source": [ "%%manim -qm -v WARNING OpeningManim\n", "\n", "class OpeningManim(Scene):\n", " def construct(self):\n", " title = Tex(r\"This is some \\LaTeX\")\n", " basel = MathTex(r\"\\sum_{n=1}^\\infty \\frac{1}{n^2} = \\frac{\\pi^2}{6}\")\n", " VGroup(title, basel).arrange(DOWN)\n", " self.play(\n", " Write(title),\n", " FadeIn(basel, shift = UP),\n", " )\n", " self.wait()\n", "\n", " transform_title = Tex(\"That was a transform\")\n", " transform_title.to_corner(UP + LEFT)\n", " self.play(\n", " Transform(title, transform_title),\n", " LaggedStart(*[FadeOut(obj, shift=DOWN) for obj in basel]),\n", " )\n", " self.wait()\n", "\n", " grid = NumberPlane(x_range=(- 10, 10, 1), y_range=(- 6.0, 6.0, 1))\n", " grid_title = Tex(\"This is a grid\")\n", " grid_title.scale(1.5)\n", " grid_title.move_to(transform_title)\n", "\n", " self.add(grid, grid_title) # Make sure title is on top of grid\n", " self.play(\n", " FadeOut(title),\n", " FadeIn(grid_title, shift=DOWN),\n", " Create(grid, run_time=3, lag_ratio=0.1),\n", " )\n", " self.wait()\n", "\n", " grid_transform_title = Tex(\n", " r\"That was a non-linear function \\\\ applied to the grid\"\n", " )\n", " grid_transform_title.move_to(grid_title, UL)\n", " grid.prepare_for_nonlinear_transform()\n", " self.play(\n", " grid.animate.apply_function(\n", " lambda p: p\n", " + np.array(\n", " [\n", " np.sin(p[1]),\n", " np.sin(p[0]),\n", " 0,\n", " ]\n", " )\n", " ),\n", " run_time=3,\n", " )\n", " self.wait()\n", " self.play(Transform(grid_title, grid_transform_title))\n", " self.wait()\n" ] }, { "cell_type": "markdown", "id": "graduate-clinic", "metadata": {}, "source": [ "See many more examples at https://docs.manim.community/en/latest/examples.html!" ] } ], "metadata": { "kernelspec": { "display_name": "manim7", "language": "python", "name": "manim7" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.5" } }, "nbformat": 4, "nbformat_minor": 5 }