"""Hello world in Manim: the smallest scene worth rendering.

Render it (p opens the video when it is done, ql is low quality and fast):

    manim -pql hello_world.py HelloWorld

Change ql to qh for the final, sharp version.
"""

from manim import *


# A scene is a class. Manim looks for classes that inherit from Scene,
# creates one, and calls its construct method. Whatever construct does,
# in order, is the video.
class HelloWorld(Scene):
    def construct(self):
        # Text is a Mobject: anything that can be drawn on screen.
        # Creating it does not show it yet, it only exists in memory.
        title = Text("Hello, world")

        # play runs one animation. Write draws the text stroke by stroke
        # and only now does it appear in the video.
        self.play(Write(title))

        # wait holds the last frame for a second so the viewer can read it.
        self.wait(1)

        # Move the title up and bring in a second line underneath.
        # Animations can be chained through .animate on any Mobject.
        self.play(title.animate.to_edge(UP))

        subtitle = Text("This is Manim", color=BLUE).next_to(title, DOWN)
        self.play(FadeIn(subtitle, shift=UP))
        self.wait(1)

        # Everything on screen fades out together to close the scene.
        self.play(FadeOut(title, subtitle))
