manim is a library that is made up of several parts the first thing manim does is use python to convert the manum figures to a special language this special language is transferred to a program called cairo turns this special language into a series of images which are all the frames of our animation at the same time that cairo generates these images it sends them to another program called ffmpeg which concatenates all these images into a video in general manam works more complex but this way you can get a rough idea of how it works if
you want to understand its source code in this first section we will teach the traditional way of using mana first you must create a python file with the extension.py in this file you will find our animations remember to configure your vs code with your virtual environment so that it recognizes the manum commands the first line of code is the import of mana into our file you must think that the code of each video rendered in manim has to go inside a class and this class must inherit from the scene class or variance you can have
multiple classes that inherit from seen in the same file but it is not recommended to have many as it can get confusing later we will teach some good practices when making complex animations with manum the scene class has an abstract method called construct this method is thought to be the function where the logic of our animation will go later we will explain in detail what these commands mean for now just copy them once you have finished your code you have to go to the terminal activate your virtual environment if you have not already done so
and move to the place where your script is located the way to use manim is as follows one type the command manum two enter the name of the script three then comes the name of the scene that is the class that inherits from seeing remember that there may be more classes that inherit from scene in the same file four at the end are the flags that indicate the video or image export process later we will go into depth with all the export options to configure the output file as video you have to use the qm
flags the q means quality and the m means medium the q flag always precedes the quality in addition to medium low or high at the end if there were no errors mana will tell you where your file is located in case you want to export the last frame of the animation you can use the s flag if you want your video or image to open automatically when rendering is complete then add a p before the other flags in case your scene has no duration that is no animations or pauses manum will automatically render your project
to image even if you explicitly indicate that it is a video all it takes is a pause for manim to render your file as video this is the traditional way to work with manim but we are going to use jupiter together with vs code to make the work more didactic copy the class we just did open the command palette and create a new notebook select the kernel where you have manim installed save the file respecting the jupiter extension the first code block as i explained at the beginning must be the manum import the meaning of
the second line has to do with the size of the preview provided by jupiter what it means is that the preview is going to take 100 of the available width you can play with other values paste the code you just made to render this code with jupiter you have to go to the beginning of the block and type double percent sign this tells jupiter that we are going to write a magic command next are the flags you can omit the p from preview in this case and at the end is the name of the scene
run the block and see what happens you may notice that the video is displayed on our notebook this is quite useful for small animations and for people who are starting with manum you may notice that the info that manam gives us is somewhat annoying to ignore these messages and only show errors at the following in your magic command another command that i recommend including is disable caching later we will explain what this means another way to work with manim is to build our file as if it were a module this function means that when python
executes our code it will use the command you see on line 20. line 19 gets the address of our dot py script so we only have to indicate the scene we want to render in the scene constant defined in line 6. using the python plugin for vs code we simply have to click on the run icon to render the scene to change the scene we just have to redefine line six remember to always save the changes before rendering your code you can redefine the constant scene as many times as you want python will take the
one that is closest to the final conditional so far this is all you need to know to be able to work with manam for this course we will be using jupiter mostly but you can follow this course however you like in the next class we will give an introduction to mobjects and the types of animations see you in the next video