Rename TexMobject -> Tex and TextMobject -> TexText

This commit is contained in:
Grant Sanderson 2021-01-18 08:20:14 -10:00
parent 3bd56bff07
commit f91c81dd6a
16 changed files with 97 additions and 97 deletions

View file

@ -10,8 +10,8 @@ from manimlib.imports import *
class OpeningManimExample(Scene):
def construct(self):
title = TextMobject("This is some \\LaTeX")
basel = TexMobject(
title = TexText("This is some \\LaTeX")
basel = Tex(
"\\sum_{n=1}^\\infty "
"\\frac{1}{n^2} = \\frac{\\pi^2}{6}"
)
@ -111,12 +111,12 @@ class TextExample(Scene):
text = Text("Here is a text", font="Consolas", font_size=90)
difference = Text(
"""
The most important difference between Text and TextMobject is that\n
you can change the font more easily, but can't use the LaTeX gramma
The most important difference between Text and TexText is that\n
you can change the font more easily, but can't use the LaTeX grammar
""",
font="Arial", font_size=24,
# t2c is a dict that you can choose color for different text
t2c={"Text": BLUE, "TextMobject": BLUE, "LaTeX": ORANGE}
t2c={"Text": BLUE, "TexText": BLUE, "LaTeX": ORANGE}
)
VGroup(text, difference).arrange(DOWN, buff=1)
self.play(Write(text))
@ -175,18 +175,18 @@ class TexTransformExample(Scene):
lines = VGroup(
# Surrounding substrings with double braces
# will ensure that those parts are separated
# out in the TexMobject. For example, here the
# TexMobject will have 5 submobjects, corresponding
# out in the Tex. For example, here the
# Tex will have 5 submobjects, corresponding
# to the strings [A^2, +, B^2, =, C^2]
TexMobject("{{A^2}} + {{B^2}} = {{C^2}}"),
TexMobject("{{A^2}} = {{C^2}} - {{B^2}}"),
Tex("{{A^2}} + {{B^2}} = {{C^2}}"),
Tex("{{A^2}} = {{C^2}} - {{B^2}}"),
# Alternatively, you can pass in the keyword argument
# isolate with a list of strings that should be out as
# their own submobject. So both lines below are equivalent
# to what you'd get by wrapping every instance of "B", "C"
# "=", "(" and ")" with double braces
TexMobject("{{A^2}} = (C + B)(C - B)", **kw),
TexMobject("A = \\sqrt{(C + B)(C - B)}", **kw)
Tex("{{A^2}} = (C + B)(C - B)", **kw),
Tex("A = \\sqrt{(C + B)(C - B)}", **kw)
)
lines.arrange(DOWN, buff=LARGE_BUFF)
for line in lines:
@ -258,8 +258,8 @@ class TexTransformExample(Scene):
# those of a target, regardless of the submobject hierarchy in
# each one, according to whether those pieces have the same
# shape (as best it can).
source = TextMobject("the morse code")
target = TextMobject("here come dots")
source = TexText("the morse code")
target = TexText("here come dots")
self.play(Write(source))
self.wait()

View file

@ -60,10 +60,10 @@ class Thumbnail(GraphScene):
triangle.scale(0.1)
#
x_label_p1 = TexMobject("a")
output_label_p1 = TexMobject("f(a)")
x_label_p2 = TexMobject("b")
output_label_p2 = TexMobject("f(b)")
x_label_p1 = Tex("a")
output_label_p1 = Tex("f(a)")
x_label_p2 = Tex("b")
output_label_p2 = Tex("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)
@ -170,7 +170,7 @@ class Thumbnail(GraphScene):
# adding manim
picture = Group(*self.mobjects)
picture.scale(0.6).to_edge(LEFT, buff=SMALL_BUFF)
manim = TextMobject("Manim").set_height(1.5) \
manim = TexText("Manim").set_height(1.5) \
.next_to(picture, RIGHT) \
.shift(DOWN * 0.7)
self.add(manim)

View file

@ -8,7 +8,7 @@ from manimlib.mobject.mobject import Mobject
from manimlib.mobject.mobject import Group
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.mobject.types.vectorized_mobject import VMobject
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.utils.config_ops import digest_config
@ -122,7 +122,7 @@ class TransformMatchingShapes(TransformMatchingParts):
class TransformMatchingTex(TransformMatchingParts):
CONFIG = {
"mobject_type": TexMobject,
"mobject_type": Tex,
"group_type": VGroup,
}

View file

@ -6,7 +6,7 @@ from manimlib.mobject.functions import ParametricCurve
from manimlib.mobject.geometry import Arrow
from manimlib.mobject.geometry import Line
from manimlib.mobject.number_line import NumberLine
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.utils.config_ops import merge_dicts_recursively
from manimlib.utils.simple_functions import binary_search
@ -69,7 +69,7 @@ class CoordinateSystem():
)
def get_axis_label(self, label_tex, axis, edge, direction, buff=MED_SMALL_BUFF):
label = TexMobject(label_tex)
label = Tex(label_tex)
label.next_to(
axis.get_edge_center(edge), direction,
buff=buff

View file

@ -5,8 +5,8 @@ from manimlib.constants import *
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 TexMobject
from manimlib.mobject.svg.tex_mobject import TextMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.svg.tex_mobject import TexText
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.mobject.types.vectorized_mobject import VMobject
@ -28,7 +28,7 @@ def matrix_to_tex_string(matrix):
def matrix_to_mobject(matrix):
return TexMobject(matrix_to_tex_string(matrix))
return Tex(matrix_to_tex_string(matrix))
def vector_coordinate_label(vector_mob, integer_labels=True,
@ -61,7 +61,7 @@ class Matrix(VMobject):
"bracket_v_buff": MED_SMALL_BUFF,
"add_background_rectangles_to_entries": False,
"include_background_rectangle": False,
"element_to_mobject": TexMobject,
"element_to_mobject": Tex,
"element_to_mobject_config": {},
"element_alignment_corner": DR,
}
@ -108,7 +108,7 @@ class Matrix(VMobject):
def add_brackets(self):
height = self.matrix.shape[0]
bracket_pair = TexMobject("".join([
bracket_pair = Tex("".join([
"\\left[",
"\\begin{array}{c}",
*height * ["\\quad \\\\"],
@ -173,22 +173,22 @@ class MobjectMatrix(Matrix):
def get_det_text(matrix, determinant=None, background_rect=False, initial_scale_factor=2):
parens = TexMobject("(", ")")
parens = Tex("(", ")")
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 = TextMobject("det")
det = TexText("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 = TexMobject("=")
eq = Tex("=")
eq.next_to(r_paren, RIGHT, buff=0.1)
result = TexMobject(str(determinant))
result = Tex(str(determinant))
result.next_to(eq, RIGHT, buff=0.2)
det_text.add(eq, result)
return det_text

View file

@ -1,5 +1,5 @@
from manimlib.constants import *
from manimlib.mobject.svg.tex_mobject import SingleStringTexMobject
from manimlib.mobject.svg.tex_mobject import SingleStringTex
from manimlib.mobject.svg.tex_mobject import tex_string_to_mob_map
from manimlib.mobject.svg.tex_mobject import SCALE_FACTOR_PER_FONT_POINT
from manimlib.mobject.types.vectorized_mobject import VMobject
@ -89,7 +89,7 @@ class DecimalNumber(VMobject):
return self.data["font_size"][0]
def string_to_mob(self, tex_string):
# Could just call SingleStringTexMobject, and there is
# Could just call SingleStringTex, and there is
# some code repetition here by looking to the same cache,
# but it keeps things from initializing a new object
# more than is necessary
@ -98,7 +98,7 @@ class DecimalNumber(VMobject):
result.scale(self.get_font_size() * SCALE_FACTOR_PER_FONT_POINT)
return result
else:
return SingleStringTexMobject(tex_string, font_size=self.get_font_size())
return SingleStringTex(tex_string, font_size=self.get_font_size())
def get_formatter(self, **kwargs):
"""

View file

@ -3,8 +3,8 @@ 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 TexMobject
from manimlib.mobject.svg.tex_mobject import TextMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.svg.tex_mobject import TexText
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.utils.color import color_gradient
from manimlib.utils.iterables import listify
@ -26,7 +26,7 @@ class SampleSpace(Rectangle):
def add_title(self, title="Sample space", buff=MED_SMALL_BUFF):
# TODO, should this really exist in SampleSpaceScene
title_mob = TextMobject(title)
title_mob = TexText(title)
if title_mob.get_width() > self.get_width():
title_mob.set_width(self.get_width())
title_mob.next_to(self, UP, buff=buff)
@ -97,7 +97,7 @@ class SampleSpace(Rectangle):
if isinstance(label, Mobject):
label_mob = label
else:
label_mob = TexMobject(label)
label_mob = Tex(label)
label_mob.scale(self.default_label_scale_val)
label_mob.next_to(brace, direction, buff)
@ -188,7 +188,7 @@ class BarChart(VGroup):
if self.label_y_axis:
labels = VGroup()
for tick, value in zip(ticks, values):
label = TexMobject(str(np.round(value, 2)))
label = Tex(str(np.round(value, 2)))
label.set_height(self.y_axis_label_height)
label.next_to(tick, LEFT, SMALL_BUFF)
labels.add(label)
@ -211,7 +211,7 @@ class BarChart(VGroup):
bar_labels = VGroup()
for bar, name in zip(bars, self.bar_names):
label = TexMobject(str(name))
label = Tex(str(name))
label.scale(self.bar_label_scale_val)
label.next_to(bar, DOWN, SMALL_BUFF)
bar_labels.add(label)

View file

@ -4,14 +4,14 @@ from manimlib.animation.composition import AnimationGroup
from manimlib.constants import *
from manimlib.animation.fading import FadeIn
from manimlib.animation.growing import GrowFromCenter
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import TextMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.svg.tex_mobject import TexText
from manimlib.mobject.types.vectorized_mobject import VMobject
from manimlib.utils.config_ops import digest_config
from manimlib.utils.space_ops import get_norm
class Brace(TexMobject):
class Brace(Tex):
CONFIG = {
"buff": 0.2,
"width_multiplier": 2,
@ -34,7 +34,7 @@ class Brace(TexMobject):
self.min_num_quads, self.max_num_quads
)
tex_string = "\\underbrace{%s}" % (num_quads * "\\qquad")
TexMobject.__init__(self, tex_string, **kwargs)
Tex.__init__(self, tex_string, **kwargs)
self.tip_point_index = np.argmin(self.get_all_points()[:, 1])
self.stretch_to_fit_width(target_width)
self.shift(left - self.get_corner(UP + LEFT) + self.buff * DOWN)
@ -56,12 +56,12 @@ class Brace(TexMobject):
return self
def get_text(self, *text, **kwargs):
text_mob = TextMobject(*text)
text_mob = TexText(*text)
self.put_at_tip(text_mob, **kwargs)
return text_mob
def get_tex(self, *tex, **kwargs):
tex_mob = TexMobject(*tex)
tex_mob = Tex(*tex)
self.put_at_tip(tex_mob, **kwargs)
return tex_mob
@ -78,7 +78,7 @@ class Brace(TexMobject):
class BraceLabel(VMobject):
CONFIG = {
"label_constructor": TexMobject,
"label_constructor": Tex,
"label_scale": 1,
}
@ -135,5 +135,5 @@ class BraceLabel(VMobject):
class BraceText(BraceLabel):
CONFIG = {
"label_constructor": TextMobject
"label_constructor": TexText
}

View file

@ -9,8 +9,8 @@ from manimlib.mobject.geometry import Rectangle
from manimlib.mobject.geometry import Square
from manimlib.mobject.mobject import Mobject
from manimlib.mobject.svg.svg_mobject import SVGMobject
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import TextMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.svg.tex_mobject import TexText
from manimlib.mobject.three_dimensions import Cube
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.mobject.types.vectorized_mobject import VMobject
@ -21,7 +21,7 @@ from manimlib.utils.space_ops import complex_to_R3
from manimlib.utils.space_ops import rotate_vector
class Checkmark(TextMobject):
class Checkmark(TexText):
CONFIG = {
"color": GREEN
}
@ -30,7 +30,7 @@ class Checkmark(TextMobject):
super().__init__("\\ding{51}")
class Exmark(TextMobject):
class Exmark(TexText):
CONFIG = {
"color": RED
}
@ -71,7 +71,7 @@ class Speedometer(VMobject):
for index, angle in enumerate(tick_angle_range):
vect = rotate_vector(RIGHT, angle)
tick = Line((1 - self.tick_length) * vect, vect)
label = TexMobject(str(10 * index))
label = Tex(str(10 * index))
label.set_height(self.tick_length)
label.shift((1 + self.tick_length) * vect)
self.add(tick, label)
@ -365,7 +365,7 @@ class Bubble(SVGMobject):
return self.content
def write(self, *text):
self.add_content(TextMobject(*text))
self.add_content(TexText(*text))
return self
def resize_to_content(self):

View file

@ -20,7 +20,7 @@ SCALE_FACTOR_PER_FONT_POINT = 0.001
tex_string_to_mob_map = {}
class SingleStringTexMobject(VMobject):
class SingleStringTex(VMobject):
CONFIG = {
"fill_opacity": 1.0,
"stroke_width": 0,
@ -131,7 +131,7 @@ class SingleStringTexMobject(VMobject):
def balance_braces(self, tex):
"""
Makes TexMobject resiliant to unmatched { at start
Makes Tex resiliant to unmatched { at start
"""
num_lefts, num_rights = [tex.count(char) for char in "{}"]
while num_rights > num_lefts:
@ -150,7 +150,7 @@ class SingleStringTexMobject(VMobject):
return self
class TexMobject(SingleStringTexMobject):
class Tex(SingleStringTex):
CONFIG = {
"arg_separator": " ",
# Note, use of isolate is largely rendered
@ -205,7 +205,7 @@ class TexMobject(SingleStringTexMobject):
tex_string = tex_string.strip()
if len(tex_string) == 0:
continue
sub_tex_mob = SingleStringTexMobject(tex_string, **config)
sub_tex_mob = SingleStringTex(tex_string, **config)
num_submobs = len(sub_tex_mob)
if num_submobs == 0:
continue
@ -227,7 +227,7 @@ class TexMobject(SingleStringTexMobject):
return tex1 == tex2
return VGroup(*filter(
lambda m: isinstance(m, SingleStringTexMobject) and test(tex, m.get_tex()),
lambda m: isinstance(m, SingleStringTex) and test(tex, m.get_tex()),
self.submobjects
))
@ -271,14 +271,14 @@ class TexMobject(SingleStringTexMobject):
return self
class TextMobject(TexMobject):
class TexText(Tex):
CONFIG = {
"math_mode": False,
"arg_separator": "",
}
class BulletedList(TextMobject):
class BulletedList(TexText):
CONFIG = {
"buff": MED_LARGE_BUFF,
"dot_scale_factor": 2,
@ -287,9 +287,9 @@ class BulletedList(TextMobject):
def __init__(self, *items, **kwargs):
line_separated_items = [s + "\\\\" for s in items]
TextMobject.__init__(self, *line_separated_items, **kwargs)
TexText.__init__(self, *line_separated_items, **kwargs)
for part in self:
dot = TexMobject("\\cdot").scale(self.dot_scale_factor)
dot = Tex("\\cdot").scale(self.dot_scale_factor)
dot.next_to(part[0], LEFT, SMALL_BUFF)
part.add_to_back(dot)
self.arrange(
@ -313,7 +313,7 @@ class BulletedList(TextMobject):
other_part.set_fill(opacity=opacity)
class TexMobjectFromPresetString(TexMobject):
class TexFromPresetString(Tex):
CONFIG = {
# To be filled by subclasses
"tex": None,
@ -322,11 +322,11 @@ class TexMobjectFromPresetString(TexMobject):
def __init__(self, **kwargs):
digest_config(self, kwargs)
TexMobject.__init__(self, self.tex, **kwargs)
Tex.__init__(self, self.tex, **kwargs)
self.set_color(self.color)
class Title(TextMobject):
class Title(TexText):
CONFIG = {
"scale_factor": 1,
"include_underline": True,
@ -337,7 +337,7 @@ class Title(TextMobject):
}
def __init__(self, *text_parts, **kwargs):
TextMobject.__init__(self, *text_parts, **kwargs)
TexText.__init__(self, *text_parts, **kwargs)
self.scale(self.scale_factor)
self.to_edge(UP)
if self.include_underline:

View file

@ -2,7 +2,7 @@ import numpy as np
from manimlib.animation.animation import Animation
from manimlib.constants import *
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.scene.scene import Scene
@ -66,7 +66,7 @@ class RearrangeEquation(Scene):
"""
num_start_terms = len(start_terms)
all_mobs = np.array(
TexMobject(start_terms).split() + TexMobject(end_terms).split())
Tex(start_terms).split() + Tex(end_terms).split())
all_terms = np.array(start_terms + end_terms)
for term in set(all_terms):
matches = all_terms == term
@ -86,7 +86,7 @@ class FlipThroughSymbols(Animation):
}
def __init__(self, tex_list, **kwargs):
mobject = TexMobject(self.curr_tex).shift(start_center)
mobject = Tex(self.curr_tex).shift(start_center)
Animation.__init__(self, mobject, **kwargs)
def interpolate_mobject(self, alpha):
@ -94,7 +94,7 @@ class FlipThroughSymbols(Animation):
if new_tex != self.curr_tex:
self.curr_tex = new_tex
self.mobject = TexMobject(new_tex).shift(self.start_center)
self.mobject = Tex(new_tex).shift(self.start_center)
if not all(self.start_center == self.end_center):
self.mobject.center().shift(
(1 - alpha) * self.start_center + alpha * self.end_center

View file

@ -1,6 +1,6 @@
from manimlib.constants import *
from manimlib.mobject.numbers import Integer
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.types.vectorized_mobject import VMobject, VGroup
from manimlib.scene.scene import Scene
from manimlib.utils.simple_functions import choose
@ -45,7 +45,7 @@ class CountingScene(Scene):
self.add(*mobjects)
for mob, num in zip(mobjects, it.count(1)):
if display_numbers:
num_mob = TexMobject(str(num))
num_mob = Tex(str(num))
num_mob.center().shift(num_offset)
self.add(num_mob)
if mode == "highlight":
@ -74,7 +74,7 @@ class CountingScene(Scene):
raise Warning("Unknown mode")
frame_time = run_time / (len(regions))
for region, count in zip(regions, it.count(1)):
num_mob = TexMobject(str(count))
num_mob = Tex(str(count))
num_mob.center().shift(num_offset)
self.add(num_mob)
self.set_color_region(region)
@ -113,7 +113,7 @@ class GeneralizedPascalsTriangle(VMobject):
]
for n, k in self.coords:
center = self.coords_to_center(n, k)
num_mob = self.submob_class(n, k) # TexMobject(str(num))
num_mob = self.submob_class(n, k) # Tex(str(num))
scale_factor = min(
1,
self.portion_to_fill * self.cell_height / num_mob.get_height(),
@ -137,7 +137,7 @@ class GeneralizedPascalsTriangle(VMobject):
def generate_n_choose_k_mobs(self):
self.coords_to_n_choose_k = {}
for n, k in self.coords:
nck_mob = TexMobject(r"{%d \choose %d}" % (n, k))
nck_mob = Tex(r"{%d \choose %d}" % (n, k))
scale_factor = min(
1,
self.portion_to_fill * self.cell_height / nck_mob.get_height(),
@ -161,7 +161,7 @@ class GeneralizedPascalsTriangle(VMobject):
return self
def generate_sea_of_zeros(self):
zero = TexMobject("0")
zero = Tex("0")
self.sea_of_zeros = []
for n in range(self.nrows):
for a in range((self.nrows - n) / 2 + 1):

View file

@ -6,7 +6,7 @@ from manimlib.constants import *
from manimlib.mobject.geometry import Arrow
from manimlib.mobject.geometry import Circle
from manimlib.mobject.geometry import Dot
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.scene.scene import Scene
@ -26,7 +26,7 @@ class CountingScene(Scene):
self.dots = VGroup()
self.number = 0
self.max_place = 0
self.number_mob = VGroup(TexMobject(str(self.number)))
self.number_mob = VGroup(Tex(str(self.number)))
self.number_mob.scale(self.num_scale_factor)
self.number_mob.shift(self.num_start_location)
@ -159,7 +159,7 @@ class CountingScene(Scene):
place = 0
max_place = self.max_place
while place < max_place:
digit = TexMobject(str(self.get_place_num(num, place)))
digit = Tex(str(self.get_place_num(num, place)))
if place >= len(self.digit_place_colors):
self.digit_place_colors += self.digit_place_colors
digit.set_color(self.digit_place_colors[place])

View file

@ -8,7 +8,7 @@ from manimlib.constants import *
from manimlib.mobject.geometry import Circle
from manimlib.mobject.geometry import Line
from manimlib.mobject.matrix import Matrix
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.scene.scene import Scene
@ -48,7 +48,7 @@ class NumericalMatrixMultiplication(Scene):
for c in range(k)
for prefix in ["" if c == 0 else "+"]
]
mob_matrix[a][b] = TexMobject(parts, next_to_buff=0.1)
mob_matrix[a][b] = Tex(parts, next_to_buff=0.1)
return Matrix(mob_matrix)
def add_lines(self, left, right):
@ -80,7 +80,7 @@ class NumericalMatrixMultiplication(Scene):
self.show_frame()
def organize_matrices(self, left, right, result):
equals = TexMobject("=")
equals = Tex("=")
everything = VGroup(left, right, equals, result)
everything.arrange()
everything.set_width(FRAME_WIDTH - 1)

View file

@ -9,8 +9,8 @@ from manimlib.mobject.geometry import Line
from manimlib.mobject.geometry import Rectangle
from manimlib.mobject.geometry import RegularPolygon
from manimlib.mobject.number_line import NumberLine
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import TextMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.svg.tex_mobject import TexText
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.mobject.types.vectorized_mobject import VectorizedPoint
from manimlib.scene.scene import Scene
@ -84,7 +84,7 @@ class GraphScene(Scene):
self.x_labeled_nums = [x for x in self.x_labeled_nums if x != 0]
x_axis.add_numbers(*self.x_labeled_nums)
if self.x_axis_label:
x_label = TextMobject(self.x_axis_label)
x_label = TexText(self.x_axis_label)
x_label.next_to(
x_axis.get_tick_marks(), UP + RIGHT,
buff=SMALL_BUFF
@ -118,7 +118,7 @@ class GraphScene(Scene):
self.y_labeled_nums = [y for y in self.y_labeled_nums if y != 0]
y_axis.add_numbers(*self.y_labeled_nums)
if self.y_axis_label:
y_label = TextMobject(self.y_axis_label)
y_label = TexText(self.y_axis_label)
y_label.next_to(
y_axis.get_corner(UP + RIGHT), UP + RIGHT,
buff=SMALL_BUFF
@ -201,7 +201,7 @@ class GraphScene(Scene):
buff=MED_SMALL_BUFF,
color=None,
):
label = TexMobject(label)
label = Tex(label)
color = color or graph.get_color()
label.set_color(color)
if x_val is None:
@ -395,11 +395,11 @@ class GraphScene(Scene):
labels = VGroup()
if dx_label is not None:
group.dx_label = TexMobject(dx_label)
group.dx_label = Tex(dx_label)
labels.add(group.dx_label)
group.add(group.dx_label)
if df_label is not None:
group.df_label = TexMobject(df_label)
group.df_label = Tex(df_label)
labels.add(group.df_label)
group.add(group.df_label)
@ -444,9 +444,9 @@ class GraphScene(Scene):
triangle.set_fill(color, 1)
triangle.set_stroke(width=0)
if label is None:
T_label = TexMobject(self.variable_point_label, fill_color=color)
T_label = Tex(self.variable_point_label, fill_color=color)
else:
T_label = TexMobject(label, fill_color=color)
T_label = Tex(label, fill_color=color)
T_label.next_to(triangle, DOWN)
v_line = self.get_vertical_line_to_graph(

View file

@ -20,8 +20,8 @@ from manimlib.mobject.matrix import Matrix
from manimlib.mobject.matrix import VECTOR_LABEL_SCALE_FACTOR
from manimlib.mobject.matrix import vector_coordinate_label
from manimlib.mobject.mobject import Mobject
from manimlib.mobject.svg.tex_mobject import TexMobject
from manimlib.mobject.svg.tex_mobject import TextMobject
from manimlib.mobject.svg.tex_mobject import Tex
from manimlib.mobject.svg.tex_mobject import TexText
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.mobject.types.vectorized_mobject import VMobject
from manimlib.scene.scene import Scene
@ -123,10 +123,10 @@ class VectorScene(Scene):
rotate=False,
color=None,
label_scale_factor=VECTOR_LABEL_SCALE_FACTOR):
if not isinstance(label, TexMobject):
if not isinstance(label, Tex):
if len(label) == 1:
label = "\\vec{\\textbf{%s}}" % label
label = TexMobject(label)
label = Tex(label)
if color is None:
color = vector.get_color()
label.set_color(color)
@ -419,7 +419,7 @@ class LinearTransformationScene(VectorScene):
def add_title(self, title, scale_factor=1.5, animate=False):
if not isinstance(title, Mobject):
title = TextMobject(title).scale(scale_factor)
title = TexText(title).scale(scale_factor)
title.to_edge(UP)
title.add_background_rectangle()
if animate: