Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Improved handling of substring isolation within sqrt, and fixed a bug with transform_mismatch for the matching shape transforms (#1527)

Benjamin Hacklf173192c7ac4
diff --git a/manim/animation/transform_matching_parts.py b/manim/animation/transform_matching_parts.py
index 96d04d1b7..b7cacbdce 100644
--- a/manim/animation/transform_matching_parts.py
+++ b/manim/animation/transform_matching_parts.py
@@ -121,8 +121,10 @@ class TransformMatchingAbstractBase(AnimationGroup):
fade_target.add(target_map[key])
if transform_mismatches:
- anims.append(Transform(fade_source.copy(), fade_target, **kwargs))
- if fade_transform_mismatches:
+ if "replace_mobject_with_target_in_scene" not in kwargs:
+ kwargs["replace_mobject_with_target_in_scene"] = True
+ anims.append(Transform(fade_source, fade_target, **kwargs))
+ elif fade_transform_mismatches:
anims.append(FadeTransformPieces(fade_source, fade_target, **kwargs))
else:
anims.append(FadeOut(fade_source, target_position=fade_target, **kwargs))
diff --git a/manim/mobject/svg/tex_mobject.py b/manim/mobject/svg/tex_mobject.py
index 5c04a068b..4426a77fb 100644
--- a/manim/mobject/svg/tex_mobject.py
+++ b/manim/mobject/svg/tex_mobject.py
@@ -287,7 +287,7 @@ class SingleStringMathTex(SVGMobject):
return result
def modify_special_strings(self, tex):
- tex = self.remove_stray_braces(tex)
+ tex = tex.strip()
should_add_filler = reduce(
op.or_,
[
@@ -296,12 +296,14 @@ class SingleStringMathTex(SVGMobject):
tex == "\\overline",
# Make sure sqrt has overbar
tex == "\\sqrt",
+ tex == "\\sqrt{",
# Need to add blank subscript or superscript
tex.endswith("_"),
tex.endswith("^"),
tex.endswith("dot"),
],
)
+
if should_add_filler:
filler = "{\\quad}"
tex += filler
@@ -325,6 +327,8 @@ class SingleStringMathTex(SVGMobject):
tex = tex.replace("\\left", "\\big")
tex = tex.replace("\\right", "\\big")
+ tex = self.remove_stray_braces(tex)
+
for context in ["array"]:
begin_in = ("\\begin{%s}" % context) in tex
end_in = ("\\end{%s}" % context) in tex