A community-maintained Python framework for creating mathematical animations.
Documentation: finish quickstart and add installation instructions (#324)
Leo Torres271c235f78d8
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 17163c0df..323a9c092 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -62,7 +62,6 @@ confusing. Here is a short guide on how to do it.git clone <your-fork-url>cd manim```-Note: do not `git clone` the original ManimCommunity repository. You mustclone your own fork. After this step, there are three differentrepositories to keep track of: the original ManimCommunity repo, your own@@ -188,6 +187,3 @@ yet-to-be-implemented changes, please mark your PR as a draft.7. Please do as much as possible to keep issues, PRs, and development ingeneral as tidy as possible.---diff --git a/docs/source/_static/installation/windows_cairo.png b/docs/source/_static/installation/windows_cairo.pngnew file mode 120000index 000000000..19c5c1956--- /dev/null+++ b/docs/source/_static/installation/windows_cairo.png@@ -0,0 +1 @@+../../../../readme-assets/windows_cairo.png\ No newline at end of filediff --git a/docs/source/_static/installation/windows_miktex.png b/docs/source/_static/installation/windows_miktex.pngnew file mode 120000index 000000000..c241a295c--- /dev/null+++ b/docs/source/_static/installation/windows_miktex.png@@ -0,0 +1 @@+../../../../readme-assets/windows_miktex.png\ No newline at end of filediff --git a/docs/source/_static/installation/windows_sox.png b/docs/source/_static/installation/windows_sox.pngnew file mode 120000index 000000000..6e9d438c8--- /dev/null+++ b/docs/source/_static/installation/windows_sox.png@@ -0,0 +1 @@+../../../../readme-assets/windows_sox.png\ No newline at end of filediff --git a/docs/source/_static/quickstart/high_quality.gif b/docs/source/_static/quickstart/high_quality.gifnew file mode 100644index 000000000..60a48a6c0Binary files /dev/null and b/docs/source/_static/quickstart/high_quality.gif differdiff --git a/docs/source/installation/arch.rst b/docs/source/installation/arch.rstdeleted file mode 100644index 1ae324409..000000000--- a/docs/source/installation/arch.rst+++ /dev/null@@ -1,2 +0,0 @@-Arch/Manjaro-============diff --git a/docs/source/installation/installation_linux.rst b/docs/source/installation/installation_linux.rstnew file mode 100644index 000000000..e69195523--- /dev/null+++ b/docs/source/installation/installation_linux.rst@@ -0,0 +1,100 @@+Linux+=====++The following instructions are given for different linux distributions that use+different package managers. After executing the instructions corresponding to+your distribution, go to `Certifying a clean install`_ to check whether the+dependencies are installed correctly. All distributions will follow the same+instructions in `Certifying a clean install`_.++The two necessary dependencies are cairo and ffmpeg. LaTeX is strongly+recommended, as it is necessary to have access to the ``TexMobject`` class.+Sox is only required if you want manim to play sounds when rendering scenes.++Ubuntu/Debian+*************++Before installing anything, make sure that your system is up to date.++.. code-block:: bash++ sudo apt update+ sudo apt upgrade++To install cairo:++.. code-block:: bash++ sudo apt install libcairo2-dev++To install ffmpeg:++.. code-block:: bash++ sudo apt install ffmpeg++To install LaTeX:++.. code-block:: bash++ sudo apt install texlive texlive-latex-extra texlive-fonts-extra \+ texlive-latex-recommended texlive-science texlive-fonts-extra tipa++To install Sox (optional):++.. code-block:: bash++ sudo apt install sox++.. note:: These instructions are also valid for other Debian-based+ distributions or distributions that use the ``apt`` package manager.+++Arch/Manjaro+************++To install cairo:++.. code-block:: bash++ sudo pacman -S cairo+++To install ffmpeg:++.. code-block:: bash++ sudo pacman -S ffmpeg++To install LaTeX:++.. code-block:: bash++ sudo pacman -S texlive-most++To install Sox (optional):++.. code-block:: bash++ sudo pacman -S sox++.. note:: These instructions are also valid for other Arch-based+ distributions or distributions that use the ``pacman`` package+ manager.+++Certifying a clean install+**************************++To check that all dependencies have been installed properly, you can execute+the commands ``ffmpeg -version`` and ``latex``. (If LaTeX is installed+properly, you will be taken to a command-line program that captures your+cursor. Press CTRL+C to exit.) To check that Sox is installed correctly,+simply run ``sox``.++.. note:: Note the LaTeX installation may take up a lot of space. The manim+ community developers are currently working on providing a simpler,+ lighter LaTeX package for you to install.++After making sure you have a clean install, you can go back to installing manim+itself in :doc:`installation_index`.diff --git a/docs/source/installation/mac.rst b/docs/source/installation/mac.rstindex 91d43f3ce..71c3495d7 100644--- a/docs/source/installation/mac.rst+++ b/docs/source/installation/mac.rst@@ -1,2 +1,70 @@Mac-=====\ No newline at end of file+===++First, you need to install Homebrew. Homebrew is a package manager similar to+``apt`` or ``pacman`` on linux that allows you to install packages easily. If+it is not installed, please install it with this command:++.. code-block:: bash++ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null++To install cairo:++.. code-block:: bash++ brew install cairo++To install ffmpeg:++.. code-block:: bash++ brew install ffmpeg++To install Sox (optional):++.. code-block:: bash++ brew install sox++To install LaTeX:++.. code-block:: bash++ brew cask install mactex++.. warning:: Note that MacTeX will require at least 4.5GB of hard disk space.+ This is due to the fact that it installs every LaTeX addon package+ offered by `CTAN <https://ctan.org/>`_. Only a few of these+ packages are required by Manim. If you would like a smaller LaTeX+ install which only contains the packages needed by Manim alone,+ consider installing BasicTeX with the instructions below. This+ will require only about 1.5GB of space. If you have installed+ MacTeX and are comfortable with it, do not install BasicTeX.++(Alternative) To install BasicTeX:++.. code-block:: bash++ brew cask install basictex++Ensure that the TeXLiveManager tool ``tlmgr`` works, by running ``tlmgr+--version`` in the terminal. Now run++.. code-block:: bash++ sudo tlmgr install standalone preview doublestroke relsize fundus-calligra \+ wasysym physics dvisvgm.x86_64-darwin dvisvgm rsfs wasy cm-super+++Certifying a clean install+**************************++To check that all dependencies have been installed properly, you can execute+the commands ``ffmpeg -version`` and ``latex`` (regardless of whether you+installed MacTeX or BasicTeX). If LaTeX is installed properly, you will be+taken to a command-line program that captures your cursor. Press CTRL+C to+exit. To check that Sox is installed correctly, simply run ``sox``.++After making sure you have a clean install, you can go back to installing manim+itself in :doc:`installation_index`.diff --git a/docs/source/installation/troubleshooting.rst b/docs/source/installation/troubleshooting.rstnew file mode 100644index 000000000..727c671a6--- /dev/null+++ b/docs/source/installation/troubleshooting.rst@@ -0,0 +1,4 @@+Troubleshooting+===============++List of known installation problems.diff --git a/docs/source/installation/ubuntu.rst b/docs/source/installation/ubuntu.rstdeleted file mode 100644index aa085f39d..000000000--- a/docs/source/installation/ubuntu.rst+++ /dev/null@@ -1,2 +0,0 @@-Ubuntu/Debian-=============diff --git a/docs/source/installation/win.rst b/docs/source/installation/win.rstindex c863dc648..abf3f05bd 100644--- a/docs/source/installation/win.rst+++ b/docs/source/installation/win.rst@@ -1,2 +1,94 @@Windows=======++First, you need to install Chocolatey, which is a package manager for Windows+systems. Please refer to `this page <https://chocolatey.org/install>`_ for+instructions.+++Cairo installation+******************++1. Visit the `Download Page+ <https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo>`_.++2. Select the download that corresponds to your PC's architechture and Python+ Version++ .. image:: ../_static/installation/windows_cairo.png+ :align: center+ :width: 400px+ :alt: windows cairo download page++ .. note:: ``cp38`` corresponds to Python 3.8, ``cp37`` corresponds to Python+ 3.7, etc. ``win_amd64`` corresponds to 64-bit machines, ``win32``+ corresponds to 32-bit machines.++3. Open up your command prompt by hitting the Win key and typing ``cmd``.++4. Enter the directory where you want to install cairo by typing ``cd+ C:\path\to\cairo`` with the path being where you downloaded the ``.whl``+ file in step 2.++5. Finally, run ``pip(pyversion) install (cairo-file).whl``, where+ ``pyversion`` is the python version you are using. For example, if you are+ using python3.7, you should run ``pip3.7 install (cairo-file).whl``.+++6. Alternatively, running the command below installs pycairo. This needs to be+ run in an elevated command prompt like Powershell.++ .. code-block:: bash++ (Invoke-WebRequest -Uri https://raw.githubusercontent.com/ManimCommunity/manim/master/scripts/pycairoinstall.py -UseBasicParsing).Content | py -3+++FFmpeg installation+*******************++1. To install ``ffmpeg`` and add it to your PATH, install `Chocolatey+ <https://chocolatey.org/>`_ and run ``choco install ffmpeg``.++2. You can check if you did it right by running ``refreshenv`` to update your+ environment variable and running ``ffmpeg``.+++Sox installation (optional)+***************************++1. To install Sox, execute ``choco install sox.portable``.++2. Add SoX to your PATH: Find the directory where SoX is installed. This is+ probably ``C:\Program Files (x86)\sox-(version_number)`` or ``C:\Program+ Files\sox-(version_number)``. Open a command prompt window by hitting the+ Win key and typing ``cmd``. Run this command to update your PATH:++ .. code-block::++ setx PATH %PATH%;C:\Program Files (x86)\sox-(version_number)++ Check whether you did it right by running ``refreshenv`` to update your environment+ variable and running ``sox``.+++LaTeX Installation+******************++1. Download the MiKTex installer from `this page+ <https://miktex.org/download>`_ and execute it.++ .. image:: ../_static/installation/windows_miktex.png+ :align: center+ :width: 500px+ :alt: windows latex download page++2. You can check if you did it right by running ``refreshenv`` to update your+ environment variable and running ``latex``.+++Certifying a clean install+**************************++After making sure you have a clean install following the instructions for each+dependency above, you can go back to installing manim itself in+:doc:`installation_index`.diff --git a/docs/source/reference.rst b/docs/source/reference.rstindex 79425b7fc..5b6c6909d 100644--- a/docs/source/reference.rst+++ b/docs/source/reference.rst@@ -16,3 +16,10 @@ last release, see the :doc:`changelog`.mobject.mobjectconfigconstants++.. This is here so that sphinx doesn't complain about changelog.rst not being+ included in any toctree+.. toctree::+ :hidden:++ changelogdiff --git a/docs/source/tutorials/a_deeper_look.md b/docs/source/tutorials/a_deeper_look.mddeleted file mode 100644index d14c32502..000000000--- a/docs/source/tutorials/a_deeper_look.md+++ /dev/null@@ -1,86 +0,0 @@-# A deeper look--[NOTE:] this is some text I wrote that was originally meant to be part of the-quickstart. However, after some thought I've decided that it's probably a bit-too much for the quickstart, as the quickstart document is supposed to showcase-the quickest way of getting up and running with manim. I've moved it here for-now, but feel free to edit/delete/move this text elsewhere in the-documentation.---## A deeper look--Let's dissect what just happened step by step. First, the following command--```bash-$ manim scene.py SquareToCircle -pl-```--executes `manim` on the file `scene.py`, which contains our animation code.-Further, this command tells manim exactly which `Scene` to be rendered, in this-case it is `SquareToCircle`. A single scene file may contain more than one-scene. Next, the flag `-p` tells manim to play the scene once it's rendered,-and the `-l` flag tells manim to render the scene in low quality.--After the video is rendered, you will see that manim has generated some new-files and the project folder will look as follows.--```-project/-├─scene.py-└─media- ├─videos- | └─scene- | └─480p15- | ├─SquareToCircle.mp4- | └─partial_movie_files- ├─text- └─Tex-```--There are quite a few new files. The main output is in-`media/videos/scene/480p15/SquareToCircle.mp4`. By default, the `media` folder-will contain all of manim's output files. The `media/videos` subfolder-contains the rendered videos. Inside of it, you will find one folder for each-different video quality. In our case, since we used the `-l` flag, the video-was generated at 480p at 15 frames per second from the `scene.py` file.-Therefore, the output can be found inside `media/videos/scene/480p15`. The-additional folders `media/videos/scene/480p15/partial_movie_files` as well as-`media/text` and `media/Tex` contain files that are used by manim internally.--You can see how manim makes use of the generated folder structure by executing-the following command,--```bash-$ manim scene.py SquareToCircle -pk-```--The `-l` flag (for low quality) has been replaced by the `-k` flag, for 4K-quality. Manim will take considerably longer to render this file, and it will-play it once it's done since we are using the `-p` flag. The output should-look like this:-[NOTE:] Output currently removed, because on a normal non 4k screen the scene is to big to be displayed.---And the folder structure should look as follows.--```-project/-├─scene.py-└─media- ├─videos- | └─scene- | ├─480p15- | | ├─SquareToCircle.mp4- | | └─partial_movie_files- | └─2160p60- | ├─SquareToCircle.mp4- | └─partial_movie_files- ├─text- └─Tex-```--Manim has created a new folder `media/videos/2160p60`, which corresponds to the-resolution and the 60 frames per second corresponding to 4k quality. Inside of-it, you can find the new `SquareToCircle.mp4`, as well as the corresponding-`partial_movie_files`.diff --git a/docs/source/tutorials/a_deeper_look.rst b/docs/source/tutorials/a_deeper_look.rstnew file mode 100644index 000000000..8bb6e8014--- /dev/null+++ b/docs/source/tutorials/a_deeper_look.rst@@ -0,0 +1,156 @@+A deeper look+=============++This document will focus on understanding manim's output files and some of the+main command line flags available.++.. note:: This tutorial picks up where :doc:`quickstart` left of, so please+ read that document before starting this one.++Manim output folders+********************++At this point, you have just executed the following command.++.. code-block:: bash++ $ manim scene.py SquareToCircle -pl++Let's dissect what just happened step by step. First, this command executes+manim on the file ``scene.py``, which contains our animation code. Further,+this command tells manim exactly which ``Scene`` to be rendered, in this case+it is ``SquareToCircle``. This is necessary because a single scene file may+contain more than one scene. Next, the flag `-p` tells manim to play the scene+once it's rendered, and the `-l` flag tells manim to render the scene in low+quality.++After the video is rendered, you will see that manim has generated some new+files and the project folder will look as follows.++.. code-block:: bash++ project/+ ├─scene.py+ └─media+ ├─videos+ | └─scene+ | └─480p15+ | ├─SquareToCircle.mp4+ | └─partial_movie_files+ ├─text+ └─Tex+++There are quite a few new files. The main output is in+``media/videos/scene/480p15/SquareToCircle.mp4``. By default, the ``media``+folder will contain all of manim's output files. The ``media/videos``+subfolder contains the rendered videos. Inside of it, you will find one folder+for each different video quality. In our case, since we used the ``-l`` flag,+the video was generated at 480 resolution at 15 frames per second from the+``scene.py`` file. Therefore, the output can be found inside+``media/videos/scene/480p15``. The additional folders+``media/videos/scene/480p15/partial_movie_files`` as well as ``media/text`` and+``media/Tex`` contain files that are used by manim internally.++You can see how manim makes use of the generated folder structure by executing+the following command,++.. code-block:: bash++ $ manim scene.py SquareToCircle -pe++The ``-l`` flag (for low quality) has been replaced by the ``-e`` flag, for+high quality. Manim will take considerably longer to render this file, and it+will play it once it's done since we are using the ``-p`` flag. The output+should look like this:++.. image:: ../_static/quickstart/high_quality.gif+ :align: center+ :alt: high quality scene output++And the folder structure should look as follows.++.. code-block:: bash++ project/+ ├─scene.py+ └─media+ ├─videos+ | └─scene+ | ├─480p15+ | | ├─SquareToCircle.mp4+ | | └─partial_movie_files+ | └─1080p60+ | ├─SquareToCircle.mp4+ | └─partial_movie_files+ ├─text+ └─Tex++Manim has created a new folder ``media/videos/1080p60``, which corresponds to+the high resolution and the 60 frames per second. Inside of it, you can find+the new ``SquareToCircle.mp4``, as well as the corresponding+``partial_movie_files``.++When working on a project with multiple scenes, and trying out multiple+resolutions, the structure of the output directories will keep all your videos+organized.++Further, manim has the option to output the last frame of a scene, when adding+the flag ``-s``. This is the fastest option to quickly get a preview of a scene.+The corresponding folder structure looks like this:++.. code-block:: bash++ project/+ ├─scene.py+ └─media+ ├─images+ | └─scene+ | ├─SquareToCircle.png+ ├─videos+ | └─scene+ | ├─480p15+ | | ├─SquareToCircle.mp4+ | | └─partial_movie_files+ | └─1080p60+ | ├─SquareToCircle.mp4+ | └─partial_movie_files+ ├─text+ └─Tex++Saving the last frame with ``-s`` can be combined with the flags for different+resolutions, e.g. ``-s -l``, ``-s -e``+++++Some command line flags+***********************++When executing the command++.. code-block:: bash++ $ manim scene.py SquareToCircle -pl++it was necessary to specify which ``Scene`` class to render. This is because a+single file can contain more than one ``Scene`` class. If your file contains+multiple ``Scene`` classes, and you want to render them all, you can use the+``-a`` flag.++As discussed previously, the ``-l`` specifies low render quality. This does+not look very good, but is very useful for rapid prototyping and testing. The+other options that specify render quality are ``-m``, ``-e``, and ``-k`` for+medium, high, and 4k quality, respectively.++The ``-p`` flag plays the animation once it is rendered. If you want to open+the file browser at the location of the animation instead of playing it, you+can use the ``-f`` flag. You can also omit these two flags.++Finally, by default manim will output .mp4 files. If you want your animations+in .gif format instead, use the ``-i`` flag. The output files will be in the+same folder as the .mp4 files, and with the same name, but different file+extension.++This was a quick review of some of the most frequent command line flags. For a+thorough review of all flags available, see :doc:`configuration`.diff --git a/docs/source/tutorials/quickstart.md b/docs/source/tutorials/quickstart.mddeleted file mode 100644index 467e6a6d7..000000000--- a/docs/source/tutorials/quickstart.md+++ /dev/null@@ -1,116 +0,0 @@-# Quickstart---This document will lead you step by step through the necessary procedure to get-`manim` up and running as soon as possible.---## Installation--[INSTALLATION INSTRUCTIONS GO HERE]. Note: when this section is done, delete-installation instructions from the GitHub repo README.--+ mention pip install-+ mention choco package-+ mention things about Cairo and LaTeX---## Start a new project--To start a new manim video project, all you need to do is choose a single-folder where all of the files related to the video will reside. For this-example, this folder will be called `project`,--```-project/-```--Every file containing code that produces a video with manim will be stored-here, as well as `manim`'s output files and configuration files.---## Your first Scene--To produce your first scene, create a new file in your project folder--```-project/-└─scene.py-```--and copy the following code in it--```python-from manim import *--# all code must be contained inside the construct-# method of a class that inherits from Scene-class SquareToCircle(Scene):- def construct(self):- circle = Circle() # create a circle- circle.set_fill(PINK, opacity=0.5) # set the color and transparency- self.play(ShowCreation(circle)) # show the circle on screen-```--Then open your command line, navigate to your project directory, and execute-the following command:--```bash-$ manim scene.py SquareToCircle -pl-```--After some output, `manim` should render the scene into a .mp4 file, and open-that file with the default movie player application. You should see a video-playing the following animation.---If you see the video and it looks correct, congrats! You just wrote your first-`manim` scene from scratch. If you get an error message instead, or if do not-see a video, or if the video output does not look like this, it is likely that-`manim` has not been installed correctly. Please refer to the Troubleshooting-page for more information.--## Some bells and whistles--Our scene is a little basic, so let's add some bells and whistles. Modify the-`scene.py` file to contain the following:--```python-from manim import *--class SquareToCircle(Scene):- def construct(self):- circle = Circle() # create a circle- circle.set_fill(PINK, opacity=0.5) # set color and transparency-- square = Square() # create a square- square.flip(RIGHT) # flip horizontally- square.rotate(-3 * TAU / 8) # rotate a certain amount-- self.play(ShowCreation(square)) # animate the creation of the square- self.play(Transform(square, circle)) # interpolate the square into the circle- self.play(FadeOut(square)) # fade out animation-```--And render it using the following command:--```bash-$ manim scene.py SquareToCircle -pl-```--The output should look as follows.----This example shows one of the most basic features of `manim`: the ability to-implement complicated and perhaps mathematically-intensive animations (such as-cleanly interpolating between two geometric shapes) in very few lines of code.---## You're done!--With a working installation of manim, and the bare basics under your belt, it-is now time to start creating awesome mathematical animations. For a more-extensive review of manim's features, as well as its configuration and other-settings, see the Tutorial page. For a list of all available features, see the-Reference page.diff --git a/docs/source/tutorials/quickstart.rst b/docs/source/tutorials/quickstart.rstnew file mode 100644index 000000000..01c21d7c7--- /dev/null+++ b/docs/source/tutorials/quickstart.rst@@ -0,0 +1,122 @@+Quickstart+==========++This document will lead you step by step through the necessary procedure to get+started with manim for the first time as soon as possible. This tutorial+assumes you have already installed manim following the steps in+:doc:`../installation/installation_index`.+++Start a new project+*******************++To start a new manim video project, all you need to do is choose a single+folder where all of the files related to the video will reside. For this+example, this folder will be called ``project``,++.. code-block:: bash++ project/++Every file containing code that produces a video with manim will be stored+here, as well as any output files that manim produces and configuration files+that manim needs.+++Your first Scene+****************++To produce your first scene, create a new file in your project folder called+``scene.py``,++.. code-block:: bash++ project/+ └─scene.py++and copy the following code in it.++.. code-block:: python++ from manim import *++ # all code must be contained inside the construct+ # method of a class that inherits from Scene+ class SquareToCircle(Scene):+ def construct(self):+ circle = Circle() # create a circle+ circle.set_fill(PINK, opacity=0.5) # set the color and transparency+ self.play(ShowCreation(circle)) # show the circle on screen++Then open your command line, navigate to your project directory, and execute+the following command:++.. code-block:: bash++ $ manim scene.py SquareToCircle -pl++After showing some output, manim should render the scene into a .mp4 file,+and open that file with the default movie player application. You should see a+video playing the following animation.++.. image:: ../_static/quickstart/first_scene.gif+ :align: center+ :alt: first scene output++If you see the video and it looks correct, congrats! You just wrote your first+manim scene from scratch. If you get an error message instead, or if do not+see a video, or if the video output does not look like this, it is likely that+manim has not been installed correctly. Please refer to the+:doc:`../installation/troubleshooting` page for more information.+++Some bells and whistles+***********************++Our scene is a little basic, so let's add some bells and whistles. Modify the+``scene.py`` file to contain the following:++.. code-block:: python++ from manim import *++ class SquareToCircle(Scene):+ def construct(self):+ circle = Circle() # create a circle+ circle.set_fill(PINK, opacity=0.5) # set color and transparency++ square = Square() # create a square+ square.flip(RIGHT) # flip horizontally+ square.rotate(-3 * TAU / 8) # rotate a certain amount++ self.play(ShowCreation(square)) # animate the creation of the square+ self.play(Transform(square, circle)) # interpolate the square into the circle+ self.play(FadeOut(square)) # fade out animation++And render it using the following command:++.. code-block:: bash++ $ manim scene.py SquareToCircle -pl++The output should look as follows.++.. image:: ../_static/quickstart/second_scene.gif+ :align: center+ :alt: second scene output++This example shows one of the most basic features of manim: the ability to+implement complicated and mathematically-intensive animations (such as cleanly+interpolating between two geometric shapes) in very few lines of code.+++You're done!+************++With a working installation of manim, and the bare basics under your belt, it+is now time to start creating awesome mathematical animations. For a look+under the hood at what manim is doing when rendering the ``SquareToCircle``+scene, see the next tutorial :doc:`a_deeper_look`. For an extensive review of+manim's features, as well as its configuration and other settings, see the+other :doc:`tutorials_index`. For a list of all available features, see the+:doc:`../reference` page.