<jupyter_start><jupyter_text>Manim Introduction Used Terminology|         |                                                                                 ||:------- |:------------------------------------------------------------------------------- || Python  | Programming Language, offering most basic elements (variables, functions, etc.) || LaTeX   | Typesetting Language (for pretty Equations)                                     || Manim   | Rendering Framework using Python and LaTeX (defines how a Circle looks like)    || Jupyter | *This* Web Environment running Python, LaTeX and Manim for your Browser         |<jupyter_code># imports have to be executed before anything else <- tell Python that we're going to use Manim
from manim import *

# click inside this cell and press Shift+Enter to run it<jupyter_output><empty_output><jupyter_text>Still Frame<jupyter_code>%%manim FirstExample
# ^ tell Jupyter to render the scene "FirstExample" and display the output

# again, use Shift+Enter to run this cell after having clicked inside of it
# you must have run the first cell prior

# mathematical function to be drawn
def funcy_curve(x):
    return (x+2)*x*(x-2)/2

# I want to define a new scene and I call it "FirstExample"
class FirstExample(Scene):
    # this is what you need to do to make me happy
    def construct(self):
        # create a coordinate system
        ax = Axes(x_range=(-3, 3), y_range=(-3, 3))
        # create our funky curve
        curve = ax.plot(funcy_curve, color=RED)
        # yes, please do render them
        self.add(ax, curve)<jupyter_output><empty_output><jupyter_text>Some Flying FramesLet's draw the coordinate system and the curve a bit more gracefully.<jupyter_code>%%manim -ql Example
# ^ -ql stands for low-quality -> takes less time to render

def funcy_curve(x):
    return (x+2)*x*(x-2)/2

class Example(Scene):
    def construct(self):
        ax = Axes(x_range=(-3, 3), y_range=(-3, 3))
        curve = ax.plot(funcy_curve, color=RED)
        # instead of self.add(...) use the Create(...) animation
        # the animation has 3 seconds of breathing room
        self.play(Create(ax, run_time=3))
        # now "Create" the curve too
        self.play(Create(curve))
        # if you uncomment this and remove the other self.play(...) calls:
        # self.play(Create(ax, run_time=3),Create(curve))
        # it will create both at the same time; try it!
        
        # it is always a good idea to end your animation with a pause (in this case 2 seconds)
        self.wait(2)
%%manim -ql Example

def funcy_curve(x):
    return (x+2)*x*(x-2)/2

# Jupyter won't kill you for using the same name twice
# though if you run this in a ".py" file (without Jupyter) every scene needs a unique name
class Example(Scene):
    def construct(self):
        ax = Axes(x_range=(-3, 3), y_range=(-3, 3))
        curve = ax.plot(funcy_curve, color=RED)
        # let's show an area under the curve
        area = ax.get_area(curve, x_range=(-2, 0))
        self.play(Create(ax, run_time=3))
        self.play(Create(curve))
        # use a more flamboyant animation
        self.play(FadeIn(area))
        
        # to make sure the viewer is properly appreciating the area, indicate it
        self.play(Indicate(area))
        
        self.wait(2)<jupyter_output><empty_output><jupyter_text>LaTeX<jupyter_code>%%manim -ql Example

class Example(Scene):
    def construct(self):
        # enter math in MathTex(r"...") using LaTeX
        # if you're interested this is using an align* environment
        # spaces get ignored
        eq = MathTex(r"2+2 =      4")
        self.add(eq)
%%manim -ql Example

class Example(Scene):
    def construct(self):
        # greek letter can be expressed with \name
        # if you desire an uppercase delta, use \Delta instead
        # \frac{a}{b} shows the fraction of a over b
        eq1 = MathTex(r"\lambda = \frac{\delta}{k}")
        # use the Write(...) animation
        self.play(Write(eq1))
        self.wait(1)
        
        # \left( and \right) create parentheses of the correct height -> any fractions don't look like they're wearing too small shoes
        eq2 = MathTex(r"\lambda = \frac{\sin\left(\alpha\right) \cdot g}{k}")
        # morph one Mobject into another
        self.play(ReplacementTransform(eq1, eq2))
        self.wait(1)
        
        # equations can get very complicated
        eq3 = MathTex(r"\lambda = \frac{\sin\left( \arctan\left( \frac{d_k}{a} \right) \right)\cdot g}{k}")
        self.play(ReplacementTransform(eq2, eq3))
        self.wait(2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12332032943216298, 'fraction_numerical': 0.00953619419159081, 'mean_word_length': 2.436336559940432, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '288152', 'license': 'MIT', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1351, 'n_words': 468, 'path': 'manim_intro_code_example.ipynb', 'repo_name': 'christopher-besch/manim_intro', 'size': '4614'}