mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Replace Tex and MTex throughout library
This commit is contained in:
parent
0d525baf29
commit
6d5b980d4a
7 changed files with 41 additions and 39 deletions
|
@ -60,10 +60,10 @@ class Thumbnail(GraphScene):
|
|||
triangle.scale(0.1)
|
||||
|
||||
#
|
||||
x_label_p1 = Tex("a")
|
||||
output_label_p1 = Tex("f(a)")
|
||||
x_label_p2 = Tex("b")
|
||||
output_label_p2 = Tex("f(b)")
|
||||
x_label_p1 = MTex("a")
|
||||
output_label_p1 = MTex("f(a)")
|
||||
x_label_p2 = MTex("b")
|
||||
output_label_p2 = MTex("f(b)")
|
||||
v_line_p1 = get_v_line(input_tracker_p1)
|
||||
v_line_p2 = get_v_line(input_tracker_p2)
|
||||
h_line_p1 = get_h_line(input_tracker_p1)
|
||||
|
|
|
@ -18,7 +18,7 @@ from manimlib.mobject.geometry import DashedLine
|
|||
from manimlib.mobject.geometry import Line
|
||||
from manimlib.mobject.geometry import Rectangle
|
||||
from manimlib.mobject.number_line import NumberLine
|
||||
from manimlib.mobject.svg.tex_mobject import Tex
|
||||
from manimlib.mobject.svg.mtex_mobject import MTex
|
||||
from manimlib.mobject.types.dot_cloud import DotCloud
|
||||
from manimlib.mobject.types.surface import ParametricSurface
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
|
@ -105,7 +105,7 @@ class CoordinateSystem(ABC):
|
|||
edge: Vect3 = RIGHT,
|
||||
direction: Vect3 = DL,
|
||||
**kwargs
|
||||
) -> Tex:
|
||||
) -> MTex:
|
||||
return self.get_axis_label(
|
||||
label_tex, self.get_x_axis(),
|
||||
edge, direction, **kwargs
|
||||
|
@ -117,7 +117,7 @@ class CoordinateSystem(ABC):
|
|||
edge: Vect3 = UP,
|
||||
direction: Vect3 = DR,
|
||||
**kwargs
|
||||
) -> Tex:
|
||||
) -> MTex:
|
||||
return self.get_axis_label(
|
||||
label_tex, self.get_y_axis(),
|
||||
edge, direction, **kwargs
|
||||
|
@ -130,8 +130,8 @@ class CoordinateSystem(ABC):
|
|||
edge: Vect3,
|
||||
direction: Vect3,
|
||||
buff: float = MED_SMALL_BUFF
|
||||
) -> Tex:
|
||||
label = Tex(label_tex)
|
||||
) -> MTex:
|
||||
label = MTex(label_tex)
|
||||
label.next_to(
|
||||
axis.get_edge_center(edge), direction,
|
||||
buff=buff
|
||||
|
@ -268,9 +268,9 @@ class CoordinateSystem(ABC):
|
|||
direction: Vect3 = RIGHT,
|
||||
buff: float = MED_SMALL_BUFF,
|
||||
color: ManimColor | None = None
|
||||
) -> Tex | Mobject:
|
||||
) -> MTex | Mobject:
|
||||
if isinstance(label, str):
|
||||
label = Tex(label)
|
||||
label = MTex(label)
|
||||
if color is None:
|
||||
label.match_color(graph)
|
||||
if x is None:
|
||||
|
@ -537,7 +537,7 @@ class ThreeDAxes(Axes):
|
|||
|
||||
def add_axis_labels(self, x_tex="x", y_tex="y", z_tex="z", font_size=24, buff=0.2):
|
||||
x_label, y_label, z_label = labels = VGroup(*(
|
||||
Tex(tex, font_size=font_size)
|
||||
MTex(tex, font_size=font_size)
|
||||
for tex in [x_tex, y_tex, z_tex]
|
||||
))
|
||||
z_label.rotate(PI / 2, RIGHT)
|
||||
|
@ -697,6 +697,7 @@ class ComplexPlane(NumberPlane):
|
|||
self,
|
||||
numbers: list[complex] | None = None,
|
||||
skip_first: bool = True,
|
||||
font_size: int = 36,
|
||||
**kwargs
|
||||
):
|
||||
if numbers is None:
|
||||
|
@ -712,7 +713,7 @@ class ComplexPlane(NumberPlane):
|
|||
else:
|
||||
axis = self.get_x_axis()
|
||||
value = z.real
|
||||
number_mob = axis.get_number_mobject(value, **kwargs)
|
||||
number_mob = axis.get_number_mobject(value, font_size=font_size, **kwargs)
|
||||
# For -i, remove the "1"
|
||||
if z.imag == -1:
|
||||
number_mob.remove(number_mob[1])
|
||||
|
|
|
@ -10,8 +10,8 @@ from manimlib.constants import WHITE
|
|||
from manimlib.mobject.numbers import DecimalNumber
|
||||
from manimlib.mobject.numbers import Integer
|
||||
from manimlib.mobject.shape_matchers import BackgroundRectangle
|
||||
from manimlib.mobject.svg.tex_mobject import Tex
|
||||
from manimlib.mobject.svg.tex_mobject import TexText
|
||||
from manimlib.mobject.svg.mtex_mobject import MTex
|
||||
from manimlib.mobject.svg.mtex_mobject import MTexText
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||
|
||||
|
@ -41,8 +41,8 @@ def matrix_to_tex_string(matrix: npt.ArrayLike) -> str:
|
|||
return prefix + R" \\ ".join(rows) + suffix
|
||||
|
||||
|
||||
def matrix_to_mobject(matrix: npt.ArrayLike) -> Tex:
|
||||
return Tex(matrix_to_tex_string(matrix))
|
||||
def matrix_to_mobject(matrix: npt.ArrayLike) -> MTex:
|
||||
return MTex(matrix_to_tex_string(matrix))
|
||||
|
||||
|
||||
def vector_coordinate_label(
|
||||
|
@ -109,7 +109,7 @@ class Matrix(VMobject):
|
|||
def element_to_mobject(self, element: str | float | VMobject, **config) -> VMobject:
|
||||
if isinstance(element, VMobject):
|
||||
return element
|
||||
return Tex(str(element), **config)
|
||||
return MTex(str(element), **config)
|
||||
|
||||
def matrix_to_mob_matrix(
|
||||
self,
|
||||
|
@ -142,11 +142,11 @@ class Matrix(VMobject):
|
|||
|
||||
def add_brackets(self, v_buff: float, h_buff: float):
|
||||
height = len(self.mob_matrix)
|
||||
brackets = Tex("".join((
|
||||
brackets = MTex("".join((
|
||||
R"\left[\begin{array}{c}",
|
||||
*height * [R"\quad \\"],
|
||||
R"\end{array}\right]",
|
||||
)))[0]
|
||||
)))
|
||||
brackets.set_height(self.get_height() + v_buff)
|
||||
l_bracket = brackets[:len(brackets) // 2]
|
||||
r_bracket = brackets[len(brackets) // 2:]
|
||||
|
@ -219,22 +219,22 @@ def get_det_text(
|
|||
background_rect: bool = False,
|
||||
initial_scale_factor: int = 2
|
||||
) -> VGroup:
|
||||
parens = Tex("(", ")")
|
||||
parens = MTex("()")
|
||||
parens.scale(initial_scale_factor)
|
||||
parens.stretch_to_fit_height(matrix.get_height())
|
||||
l_paren, r_paren = parens.split()
|
||||
l_paren.next_to(matrix, LEFT, buff=0.1)
|
||||
r_paren.next_to(matrix, RIGHT, buff=0.1)
|
||||
det = TexText("det")
|
||||
det = MTexText("det")
|
||||
det.scale(initial_scale_factor)
|
||||
det.next_to(l_paren, LEFT, buff=0.1)
|
||||
if background_rect:
|
||||
det.add_background_rectangle()
|
||||
det_text = VGroup(det, l_paren, r_paren)
|
||||
if determinant is not None:
|
||||
eq = Tex("=")
|
||||
eq = MTex("=")
|
||||
eq.next_to(r_paren, RIGHT, buff=0.1)
|
||||
result = Tex(str(determinant))
|
||||
result = MTex(str(determinant))
|
||||
result.next_to(eq, RIGHT, buff=0.2)
|
||||
det_text.add(eq, result)
|
||||
return det_text
|
||||
|
|
|
@ -9,7 +9,7 @@ from manimlib.mobject.geometry import Line
|
|||
from manimlib.mobject.geometry import Rectangle
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.mobject.svg.brace import Brace
|
||||
from manimlib.mobject.svg.tex_mobject import Tex
|
||||
from manimlib.mobject.svg.mtex_mobject import MTex
|
||||
from manimlib.mobject.svg.tex_mobject import TexText
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
from manimlib.utils.color import color_gradient
|
||||
|
@ -132,7 +132,7 @@ class SampleSpace(Rectangle):
|
|||
if isinstance(label, Mobject):
|
||||
label_mob = label
|
||||
else:
|
||||
label_mob = Tex(label)
|
||||
label_mob = MTex(label)
|
||||
label_mob.scale(self.default_label_scale_val)
|
||||
label_mob.next_to(brace, direction, buff)
|
||||
|
||||
|
@ -266,7 +266,7 @@ class BarChart(VGroup):
|
|||
if self.label_y_axis:
|
||||
labels = VGroup()
|
||||
for y_tick, value in zip(y_ticks, values):
|
||||
label = Tex(str(np.round(value, 2)))
|
||||
label = MTex(str(np.round(value, 2)))
|
||||
label.set_height(self.y_axis_label_height)
|
||||
label.next_to(y_tick, LEFT, SMALL_BUFF)
|
||||
labels.add(label)
|
||||
|
@ -289,7 +289,7 @@ class BarChart(VGroup):
|
|||
|
||||
bar_labels = VGroup()
|
||||
for bar, name in zip(bars, self.bar_names):
|
||||
label = Tex(str(name))
|
||||
label = MTex(str(name))
|
||||
label.scale(self.bar_label_scale_val)
|
||||
label.next_to(bar, DOWN, SMALL_BUFF)
|
||||
bar_labels.add(label)
|
||||
|
|
|
@ -12,7 +12,7 @@ from manimlib.animation.composition import AnimationGroup
|
|||
from manimlib.animation.fading import FadeIn
|
||||
from manimlib.animation.growing import GrowFromCenter
|
||||
from manimlib.mobject.svg.tex_mobject import SingleStringTex
|
||||
from manimlib.mobject.svg.tex_mobject import Tex
|
||||
from manimlib.mobject.svg.mtex_mobject import MTex
|
||||
from manimlib.mobject.svg.tex_mobject import TexText
|
||||
from manimlib.mobject.svg.text_mobject import Text
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
|
@ -92,8 +92,8 @@ class Brace(SingleStringTex):
|
|||
self.put_at_tip(text_mob, buff=buff)
|
||||
return text_mob
|
||||
|
||||
def get_tex(self, *tex: str, **kwargs) -> Tex:
|
||||
tex_mob = Tex(*tex)
|
||||
def get_tex(self, *tex: str, **kwargs) -> MTex:
|
||||
tex_mob = MTex(*tex)
|
||||
self.put_at_tip(tex_mob, **kwargs)
|
||||
return tex_mob
|
||||
|
||||
|
@ -109,7 +109,7 @@ class Brace(SingleStringTex):
|
|||
|
||||
|
||||
class BraceLabel(VMobject):
|
||||
label_constructor: type = Tex
|
||||
label_constructor: type = MTex
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
|
|
@ -42,9 +42,10 @@ from manimlib.mobject.geometry import Polygon
|
|||
from manimlib.mobject.geometry import Rectangle
|
||||
from manimlib.mobject.geometry import Square
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.mobject.numbers import Integer
|
||||
from manimlib.mobject.svg.svg_mobject import SVGMobject
|
||||
from manimlib.mobject.svg.tex_mobject import Tex
|
||||
from manimlib.mobject.svg.tex_mobject import TexText
|
||||
from manimlib.mobject.svg.mtex_mobject import MTex
|
||||
from manimlib.mobject.svg.mtex_mobject import MTexText
|
||||
from manimlib.mobject.svg.special_tex import TexTextFromPresetString
|
||||
from manimlib.mobject.three_dimensions import Prismify
|
||||
from manimlib.mobject.three_dimensions import VCube
|
||||
|
@ -125,7 +126,7 @@ class Speedometer(VMobject):
|
|||
for index, angle in enumerate(tick_angle_range):
|
||||
vect = rotate_vector(RIGHT, angle)
|
||||
tick = Line((1 - tick_length) * vect, vect)
|
||||
label = Tex(str(10 * index))
|
||||
label = Integer(10 * index)
|
||||
label.set_height(tick_length)
|
||||
label.shift((1 + tick_length) * vect)
|
||||
self.add(tick, label)
|
||||
|
@ -426,7 +427,7 @@ class Bubble(SVGMobject):
|
|||
return self.content
|
||||
|
||||
def write(self, *text):
|
||||
self.add_content(TexText(*text))
|
||||
self.add_content(MTexText(*text))
|
||||
return self
|
||||
|
||||
def resize_to_content(self, buff=0.75):
|
||||
|
|
|
@ -17,7 +17,7 @@ from manimlib.mobject.geometry import Square
|
|||
from manimlib.mobject.mobject import Group
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.mobject.numbers import DecimalNumber
|
||||
from manimlib.mobject.svg.tex_mobject import Tex
|
||||
from manimlib.mobject.svg.mtex_mobject import MTex
|
||||
from manimlib.mobject.svg.text_mobject import Text
|
||||
from manimlib.mobject.types.dot_cloud import DotCloud
|
||||
from manimlib.mobject.types.vectorized_mobject import VGroup
|
||||
|
@ -61,7 +61,7 @@ class InteractiveScene(Scene):
|
|||
Command + 'c' copies the ids of selections to clipboard
|
||||
Command + 'v' will paste either:
|
||||
- The copied mobject
|
||||
- A Tex mobject based on copied LaTeX
|
||||
- A MTex mobject based on copied LaTeX
|
||||
- A Text mobject based on copied Text
|
||||
Command + 'z' restores selection back to its original state
|
||||
Command + 's' saves the selected mobjects to file
|
||||
|
@ -358,7 +358,7 @@ class InteractiveScene(Scene):
|
|||
# Otherwise, treat as tex or text
|
||||
if set("\\^=+").intersection(clipboard_str): # Proxy to text for LaTeX
|
||||
try:
|
||||
new_mob = Tex(clipboard_str)
|
||||
new_mob = MTex(clipboard_str)
|
||||
except LatexError:
|
||||
return
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue