def construct(self): normal_text = Text("Text : a^2 + b^2 = c^2") # normal text object normal_mode = Tex( "Tex (Normal-Mode): a\\textsuperscript{2} + b\\textsuperscript{2} = c\\textsuperscript{2}" ) # LaTeX normal math_mode = Tex( "Tex (Math-Mode): $a^2 + b^2 = c^2$") # LaTeX Math-mode manim_math = MathTex("MathTex : a^2 + b^2 = c^2") # Manim MathLaTeX # position objects (default: center) normal_text.shift(UP * 3) normal_mode.shift(UP) math_mode.shift(DOWN) manim_math.shift(DOWN * 3) self.add(normal_text, normal_mode, math_mode, manim_math) # add objects to the scene canvas self.wait(3) # 3 second pause (default: 1 sec)
def construct(self): # Setup axes and show their creation self.setup_axes(animate=True) # Get parametric curves func_graph = self.get_graph(np.cos, color=nq_colors["steelblue"]) func_graph2 = self.get_graph(np.sin, color=nq_colors["light_purple"]) # Get vetical line from x axis to first graph vert_line = self.get_vertical_line_to_graph(x=2 * math.pi, graph=func_graph, color=nq_colors["orange"]) # Set label texts graph_lab = self.get_graph_label(func_graph, label="\\cos(x)", x_val=5, direction=UP / 2) two_pi = MathTex(r"x = 2 \pi") # Get y-point from first line label_coord = self.input_to_graph_point(x=2 * math.pi, graph=func_graph) # Set label next to point we found two_pi.next_to(label_coord, RIGHT + UP) # Animate self.play(ShowCreation(func_graph), run_time=2) self.wait(0.2) self.play(ShowCreation(func_graph2), run_time=2) self.wait(1) self.play(ShowCreation(vert_line), run_time=1) self.add(func_graph2, graph_lab, two_pi) self.wait(3)
def create_label_tex(label_tex) -> "Mobject": """Checks if the label is a ``float``, ``int`` or a ``str`` and creates a :class:`~.MathTex`/:class:`~.Tex` label accordingly. Parameters ---------- label_tex : The label to be compared against the above types. Returns ------- :class:`~.Mobject` The label. """ if isinstance(label_tex, float) or isinstance(label_tex, int): label_tex = MathTex(label_tex) elif isinstance(label_tex, str): label_tex = Tex(label_tex) return label_tex
def construct(self): txt = MathTex("a^2 + b^2 = c^2") self.add(txt) self.wait()