Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Some bug fixes associated with new copy method

Grant Sanderson6ab2d5f3b26e
diff --git a/mobject/tex_mobject.py b/mobject/tex_mobject.py
index 1aeb17d09..c31603ebf 100644
--- a/mobject/tex_mobject.py
+++ b/mobject/tex_mobject.py
@@ -128,6 +128,20 @@ class TexMobject(SVGMobject):
if test(tex, part_tex)
]
+ def copy(self):
+ ## TODO, is this the best way?
+ copy_mobject = SVGMobject.copy(self)
+ if hasattr(self, "expression_parts"):
+ pairs = zip(
+ self.submobject_family(),
+ copy_mobject.submobject_family()
+ )
+ for submob, copy_submob in pairs:
+ if submob in self.original_submobjects:
+ index = self.original_submobjects.index(submob)
+ copy_mobject.original_submobjects[index] = copy_submob
+ return copy_mobject
+
def get_part_by_tex(self, tex, **kwargs):
all_parts = self.get_parts_by_tex(tex, **kwargs)
return all_parts[0] if all_parts else None
diff --git a/mobject/vectorized_mobject.py b/mobject/vectorized_mobject.py
index c6fb8be67..288c1960a 100644
--- a/mobject/vectorized_mobject.py
+++ b/mobject/vectorized_mobject.py
@@ -200,7 +200,7 @@ class VMobject(Mobject):
but will be tracked in a separate special list for when
it comes time to display.
"""
- subpath_mobject = VMobject()
+ subpath_mobject = self.copy()##Really helps to be of the same class
subpath_mobject.is_subpath = True
subpath_mobject.set_points(points)
self.add(subpath_mobject)