mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
* refactor numbers.py, numbers.py now uses font_size, adjust constants in tex_mobject.py and text_mobject, remove uses of number_scale_value in favour of font_size * adjust PolarPlane to use font_size instead of scaling * some of the docs have been changed to use font_size, adjust constant and add font_size to markup text * accurate scale factors * code mobject compatibility with font_size * number_line now takes font_size * make tests work * cleanup * deprecated test raised error, fixed * typing for NumberLine * fix misbehaving test * actually fix set_value * use native font_size scaling for text_mobject.py * add constant and adjust BraceLabel * fix change_label * drop scale_factor for Title * add some supers * maybe fixes import issues * numberplanetest * the merge conflict is over and the tests run * add test for tex_size * some changes to the docs * properly deprecate instead of removing * move deprecations to __init__ * drop the config * deprecate number_Scale_value * update version number for deprecation * adjust test precision * if TYPE_CHECKING check * adjust Using Text * add font_size parameters for numberline and fix bug with decimal_number_config * make set_value work with opengl * make kwarg * fix typo * another typo * change dates * add font_size property for tex_mobjects * _font_size instead of font_size (prep for prop) * accidental bugfix, handle separately) * generalize text2svg * add font_size property for text_mobject.py * add check for greater than 0 * Attribute error in dd_labels * str for attr in hasattr * rewrite and fix tests * remove debugging print * fix error when self.height ==0 * Apply suggestions from code review Co-authored-by: Darylgolden <darylgolden@gmail.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * revert accidental @deprecated change * fix error in line_spacing * slight fixes * use private attribute when checking for font_size in add_labels() * raise a Value error when font_size < 0 + improve docs * Apply suggestions from code review Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at> * deprecate azimuth_label_scale and use more descriptive deprecation message * wrong number of dots for an import * add font_size property for decimalmobject * return to using public attribute * remove redundant constant * add comment Co-authored-by: Darylgolden <darylgolden@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
131 lines
3.8 KiB
Python
131 lines
3.8 KiB
Python
#!/usr/bin/env python
|
|
|
|
from manim import *
|
|
|
|
# To watch one of these scenes, run the following:
|
|
# python --quality m manim -p example_scenes.py SquareToCircle
|
|
#
|
|
# Use the flag --quality l for a faster rendering at a lower quality.
|
|
# Use -s to skip to the end and just save the final frame
|
|
# Use the -p to have preview of the animation (or image, if -s was
|
|
# used) pop up once done.
|
|
# Use -n <number> to skip ahead to the nth animation of a scene.
|
|
# Use -r <number> to specify a resolution (for example, -r 1920,1080
|
|
# for a 1920x1080 video)
|
|
|
|
|
|
class OpeningManim(Scene):
|
|
def construct(self):
|
|
title = Tex(r"This is some \LaTeX")
|
|
basel = MathTex(r"\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}")
|
|
VGroup(title, basel).arrange(DOWN)
|
|
self.play(
|
|
Write(title),
|
|
FadeIn(basel, shift=DOWN),
|
|
)
|
|
self.wait()
|
|
|
|
transform_title = Tex("That was a transform")
|
|
transform_title.to_corner(UP + LEFT)
|
|
self.play(
|
|
Transform(title, transform_title),
|
|
LaggedStart(*(FadeOut(obj, shift=DOWN) for obj in basel)),
|
|
)
|
|
self.wait()
|
|
|
|
grid = NumberPlane()
|
|
grid_title = Tex("This is a grid", font_size=72)
|
|
grid_title.move_to(transform_title)
|
|
|
|
self.add(grid, grid_title) # Make sure title is on top of grid
|
|
self.play(
|
|
FadeOut(title),
|
|
FadeIn(grid_title, shift=UP),
|
|
Create(grid, run_time=3, lag_ratio=0.1),
|
|
)
|
|
self.wait()
|
|
|
|
grid_transform_title = Tex(
|
|
r"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.animate.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):
|
|
def construct(self):
|
|
circle = Circle()
|
|
square = Square()
|
|
square.flip(RIGHT)
|
|
square.rotate(-3 * TAU / 8)
|
|
circle.set_fill(PINK, opacity=0.5)
|
|
|
|
self.play(Create(square))
|
|
self.play(Transform(square, circle))
|
|
self.play(FadeOut(square))
|
|
|
|
|
|
class WarpSquare(Scene):
|
|
def construct(self):
|
|
square = Square()
|
|
self.play(
|
|
ApplyPointwiseFunction(
|
|
lambda point: complex_to_R3(np.exp(R3_to_complex(point))), square
|
|
)
|
|
)
|
|
self.wait()
|
|
|
|
|
|
class WriteStuff(Scene):
|
|
def construct(self):
|
|
example_text = Tex("This is a some text", tex_to_color_map={"text": YELLOW})
|
|
example_tex = MathTex(
|
|
"\\sum_{k=1}^\\infty {1 \\over k^2} = {\\pi^2 \\over 6}",
|
|
)
|
|
group = VGroup(example_text, example_tex)
|
|
group.arrange(DOWN)
|
|
group.width = config["frame_width"] - 2 * LARGE_BUFF
|
|
|
|
self.play(Write(example_text))
|
|
self.play(Write(example_tex))
|
|
self.wait()
|
|
|
|
|
|
class UpdatersExample(Scene):
|
|
def construct(self):
|
|
decimal = DecimalNumber(
|
|
0,
|
|
show_ellipsis=True,
|
|
num_decimal_places=3,
|
|
include_sign=True,
|
|
)
|
|
square = Square().to_edge(UP)
|
|
|
|
decimal.add_updater(lambda d: d.next_to(square, RIGHT))
|
|
decimal.add_updater(lambda d: d.set_value(square.get_center()[1]))
|
|
self.add(square, decimal)
|
|
self.play(
|
|
square.animate.to_edge(DOWN),
|
|
rate_func=there_and_back,
|
|
run_time=5,
|
|
)
|
|
self.wait()
|
|
|
|
|
|
# See many more examples at https://docs.manim.community/en/stable/examples.html
|