A community-maintained Python framework for creating mathematical animations.
New example for gallery and some docs refinements (#1415)
Jan-Hendrik Müller0690508b580a
diff --git a/docs/source/examples.rst b/docs/source/examples.rstindex ca8e2d750..1e1318b73 100644--- a/docs/source/examples.rst+++ b/docs/source/examples.rst@@ -308,6 +308,33 @@ Plotting with Manimtwo_pi.next_to(label_coord, RIGHT + UP)self.add(func_graph, func_graph2, vert_line, graph_lab, graph_lab2, two_pi)++.. manim:: ArgMinExample++ class ArgMinExample(Scene):+ def construct(self):+ ax = Axes(+ x_range=[0, 10], y_range=[0, 100, 10], axis_config={"include_tip": False}+ )+ labels = ax.get_axis_labels(x_label="x", y_label="f(x)")++ t = ValueTracker(0)++ def func(x):+ return 2 * (x - 5) ** 2+ graph = ax.get_graph(func, color=MAROON)++ initial_point = [ax.coords_to_point(t.get_value(), func(t.get_value()))]+ dot = Dot(point=initial_point)++ dot.add_updater(lambda x: x.move_to(ax.c2p(t.get_value(), func(t.get_value()))))+ x_space = np.linspace(*ax.x_range[:2],200)+ minimum_index = func(x_space).argmin()++ self.add(ax, labels, graph, dot)+ self.play(t.animate.set_value(x_space[minimum_index]))+ self.wait()+.. manim:: GraphAreaPlot:save_last_frame::ref_modules: manim.scenes.graph_scene@@ -572,6 +599,8 @@ Special Camera Settingsself.add(axes,gauss_plane)++Advanced Projects=================diff --git a/manim/mobject/svg/tex_mobject.py b/manim/mobject/svg/tex_mobject.pyindex 7de7c0e4f..6ef4c49e3 100644--- a/manim/mobject/svg/tex_mobject.py+++ b/manim/mobject/svg/tex_mobject.py@@ -1,9 +1,10 @@r"""Mobjects representing text rendered using LaTeX.+.. note::+ Just as you can use :class:`~.Text` (from the module :mod:`~.text_mobject`) to add text to your videos, you can use :class:`~.Tex` and :class:`~.MathTex` to insert LaTeX.The Tex mobject+++++++++++++++-Just as you can use :class:`~.Text` to add text to your videos, you can use :class:`~.Tex` to insert LaTeX... manim:: HelloLaTeX:save_last_frame:diff --git a/manim/mobject/svg/text_mobject.py b/manim/mobject/svg/text_mobject.pyindex 04aade586..2ddc5f19d 100644--- a/manim/mobject/svg/text_mobject.py+++ b/manim/mobject/svg/text_mobject.py@@ -1,5 +1,9 @@"""Mobjects used for displaying (non-LaTeX) text.+.. note::+ Just as you can use :class:`~.Tex` and :class:`~.MathTex` (from the module :mod:`~.tex_mobject`) to insert LaTeX to your videos, you can use :class:`~.Text` to to add normal text.++The simplest way to add text to your animations is to use the :class:`~.Text` class. It uses the Pango library to render text.With Pango, you are also able to render non-English alphabets like `你好` or `こんにちは` or `안녕하세요` or `مرحبا بالعالم`.@@ -24,18 +28,14 @@ Examplesself.add(title.to_edge(UP))t1 = Text("1. Measuring").set_color(WHITE)- t1.next_to(ORIGIN, direction=RIGHT, aligned_edge=UP)t2 = Text("2. Clustering").set_color(WHITE)- t2.next_to(t1, direction=DOWN, aligned_edge=LEFT)t3 = Text("3. Regression").set_color(WHITE)- t3.next_to(t2, direction=DOWN, aligned_edge=LEFT)t4 = Text("4. Prediction").set_color(WHITE)- t4.next_to(t3, direction=DOWN, aligned_edge=LEFT)- x = VGroup(t1, t2, t3, t4).scale_in_place(0.7)+ x = VGroup(t1, t2, t3, t4).arrange(direction=DOWN, aligned_edge=LEFT).scale_in_place(0.7).next_to(ORIGIN,DR)x.set_opacity(0.5)x.submobjects[1].set_opacity(1)self.add(x)