Step 3 - Render images¶
Once we have our txt file in FORMULAS/TXT/ we must obtain the subindex that Manim gives each formula, for that we will use the file export_images.py that is in the FORMULAS/ folder.
This file is not made to be edited in its entirety, only certain parts, when opening it, the first lines are as follows:
1 2 3 4 5 6 7 8 9 10 11 | from manimlib.imports import *
from io import *
# OPTIONS
FILE = "quadratic"
TEX_CLASS = TexMobject
SCALE = 0.016
NUMBER_DIRECTION = DOWN
NUMBER_BUFF = 0.01
FORMULA_NUMBER_HEIGHT = 0.7
|
In FILE we write the name of the txt file that contains the list of formulas (without the txt extension).
In TEX_CLASS we write TexMobject, TextMobject or Text, in the case of formulas we write TexMobject, but if we want to include plain text with formulas we use TextMobject. That is:
formula = TextMobject("$\\frac{x^2}{y}$ This is a inline formula")
formula = TextMobject("$\\displaystyle\\frac{x^2}{y}$ This is a displayed formula")
Once the changes are made, open a terminal in the Manim main directory (where manim.py is) and execute this code as:
python -m manim FORMULAS/export_images.py -s
This will generate a folder in FORMULAS that will have the same name as the txt file (in capital letters) and a subfolder called IMAGES, like this:
FORMULAS
├── QUADRATIC
│ └── IMAGES
│ ├── im_1.png
│ ├── ....
│ └── im_15.png
└── TXT
└── quadratic.txt
In the IMAGES/ folder you are going to create the images that we are going to use to enter the real subscripts to make the animations.
The remaining parameters are as follows:
SCALE = 0.016: It is the scale of the subscripts with respect to the size of the entire formula, that is, the subscripts are \(1.6\%\) of the size of the entire formula.NUMBER_DIRECTION = DOWN: The direction where the indices will be located, that isDOWN,UP,LEFTorRIGHT.NUMBER_BUFF = 0.01: Distance between each element of the formula and its subindex.FORMULA_NUMBER_HEIGHT = 0.7: It is the size (height) of the formula number.