Generate a Manim animation for the following description. Output ONLY the Python code,…
- User
Generate a Manim animation for the following description. Output ONLY the Python code, wrapped in triple backticks (
python ...). Description: gravityNOTE!!!: Make sure the objects or text in the generated code are not overlapping at any point in the video. Make sure that each scene is properly cleaned up before transitioning to the next scene. IMPORTANT: Never assign a value to AUDIO*_DURATION placeholders. Only use them as arguments in function calls, e.g., self.wait(AUDIO1_DURATION). Do not write lines like AUDIO1_DURATION = ... or AUDIO2_DURATION = ... in the code. Only use rate functions that exist in manim.utils.rate_functions for Manim v0.18.1, such as linear, smooth, rush_into, rush_from, there_and_back, ease_in_sine, ease_out_sine, etc. Do NOT use ease_in or any function that does not exist.
- Assistant
from manim import * from manim.utils.rate_functions import ease_in_sine class GravityScene(Scene): def construct(self): # Create ground line ground = Line(LEFT * 6, RIGHT * 6).shift(DOWN * 2) ground.set_color(DARK_GREEN) # Create a ball ball = Circle(radius=0.3, color=BLUE, fill_opacity=1) ball.move_to(UP * 3) # Label for gravity vector gravity_vec = Arrow(start=ORIGIN, end=DOWN * 1, color=RED) gravity_label = MathTex(r"\vec{g}").next_to(gravity_vec, LEFT) gravity_group = VGroup(gravity_vec, gravity_label).next_to(ball, RIGHT) # Text explaining gravity gravity_text = Text("Gravity pulls objects downwards").to_edge(UP) # Scene 1: Show ground, ball, and gravity vector with label self.play(Create(ground)) self.play(FadeIn(ball)) self.play(Create(gravity_group)) self.play(Write(gravity_text)) self.wait() self.play( # Ball falls down under gravity with ease_in_sine rate function ball.animate.move_to(DOWN * 1.7), run_time=2, rate_func=ease_in_sine ) self.wait() # Remove everything to clean scene self.play( *[FadeOut(mob) for mob in [ball, gravity_group, ground, gravity_text]] ) self.wait()