mirror of
https://github.com/3b1b/manim.git
synced 2025-08-03 04:04:36 +08:00
Added new opening example in example_scenes.py
This commit is contained in:
@ -3,12 +3,70 @@
|
||||
from big_ol_pile_of_manim_imports import *
|
||||
|
||||
# To watch one of these scenes, run the following:
|
||||
# python extract_scene.py file_name <SceneName> -p
|
||||
# python -m manim example_scenes.py SquareToCircle -pl
|
||||
#
|
||||
# Use the flat -l for a faster rendering at a lower
|
||||
# quality, use -s to skip to the end and just show
|
||||
# the final frame, and use -n <number> to skip ahead
|
||||
# to the n'th animation of a scene.
|
||||
# quality.
|
||||
# Use -s to skip to the end and just show the final frame
|
||||
# Use the -p to have the animation pop up once done.
|
||||
# Use -n <number> to skip ahead to the n'th animation of a scene.
|
||||
|
||||
|
||||
class OpeningManimExample(Scene):
|
||||
def construct(self):
|
||||
title = TextMobject("This is some \\LaTeX")
|
||||
basel = TexMobject(
|
||||
"\\sum_{n=1}^\\infty "
|
||||
"\\frac{1}{n^2} = \\frac{\\pi^2}{6}"
|
||||
)
|
||||
VGroup(title, basel).arrange_submobjects(DOWN)
|
||||
self.play(
|
||||
Write(title),
|
||||
FadeInFrom(basel, UP),
|
||||
)
|
||||
self.wait()
|
||||
|
||||
transform_title = TextMobject("That was a transform")
|
||||
transform_title.to_corner(UP + LEFT)
|
||||
self.play(
|
||||
Transform(title, transform_title),
|
||||
LaggedStart(FadeOutAndShiftDown, basel),
|
||||
)
|
||||
self.wait()
|
||||
|
||||
grid = NumberPlane()
|
||||
grid_title = TextMobject("This is a grid")
|
||||
grid_title.scale(1.5)
|
||||
grid_title.move_to(transform_title)
|
||||
|
||||
self.add(grid, grid_title) # Make sure title is on top of grid
|
||||
self.play(
|
||||
FadeOut(title),
|
||||
FadeInFromDown(grid_title),
|
||||
Write(grid),
|
||||
)
|
||||
self.wait()
|
||||
|
||||
grid_transform_title = TextMobject(
|
||||
"That was a non-linear function \\\\"
|
||||
"applied to the grid"
|
||||
)
|
||||
grid_transform_title.move_to(grid_title, UL)
|
||||
grid.prepare_for_nonlinear_transform()
|
||||
self.play(
|
||||
grid.apply_function,
|
||||
lambda p: p + np.array([
|
||||
np.sin(p[1]),
|
||||
np.sin(p[0]),
|
||||
0,
|
||||
]),
|
||||
run_time=3,
|
||||
)
|
||||
self.wait()
|
||||
self.play(
|
||||
Transform(grid_title, grid_transform_title)
|
||||
)
|
||||
self.wait()
|
||||
|
||||
|
||||
class SquareToCircle(Scene):
|
||||
|
Reference in New Issue
Block a user