visit
Manim is a python library used to create beautiful animation, especially if you want to visualize a mathematical concept. it was invented by 3blue1brown.
!sudo apt update
!sudo apt install libcairo2-dev ffmpeg \
texlive texlive-latex-extra texlive-fonts-extra \
texlive-latex-recommended texlive-science \
tipa libpango1.0-dev
!pip install manim
!pip install IPython — upgrade
The next step is to all classes, methods and functions from the library.
from manim import *
# we use this line to run our code in jupyter or colab notebook specifying our quality of rendering
%%manim -qm -v WARNING TraceDot
#create a class that will inherit from the Scene class
# we create the canvas for dispaying our mobject
class TraceDot(Scene):
# This method is where we implement our animation
def construct(self):
# we instatiate our Dot object and move 2 Munit to the right from origin
a = Dot(RIGHT * 2)
# we instatiate our trace object from the tracepath class
b = TracedPath(a.get_center, dissipating_time=0.9, stroke_opacity=[0, 1])
# we add our object to the scene canvas
self.add(a, b)
# we animate our dot rotating in a circle counterclock wise and shifting from original position define above two Munit left
self.play(a.animate(path_arc=8).shift(LEFT * 2), run_time=2)
# we animate our dot rotating in a circle clock wise and shifting two Munit left further
self.play(a.animate(path_arc=-8 ).shift(LEFT * 2), run_time=2)
# we animate our dot rotating in a circle counterclock wise and two Munit left further
self.play(a.animate(path_arc=8 ).shift(LEFT * 2), run_time=2)
self.wait()