Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Added a couple helpful debugging functions

Grant Sanderson84e7bdb2b1f4
diff --git a/manimlib/imports.py b/manimlib/imports.py
index b6fd097ba..23c1498e8 100644
--- a/manimlib/imports.py
+++ b/manimlib/imports.py
@@ -86,6 +86,7 @@ from manimlib.scene.zoomed_scene import *
from manimlib.utils.bezier import *
from manimlib.utils.color import *
from manimlib.utils.config_ops import *
+from manimlib.utils.debug import *
from manimlib.utils.images import *
from manimlib.utils.iterables import *
from manimlib.utils.file_ops import *
diff --git a/manimlib/utils/debug.py b/manimlib/utils/debug.py
new file mode 100644
index 000000000..b01ee2bfa
--- /dev/null
+++ b/manimlib/utils/debug.py
@@ -0,0 +1,21 @@
+from manimlib.constants import BLACK
+from manimlib.mobject.numbers import Integer
+from manimlib.mobject.types.vectorized_mobject import VGroup
+
+
+def print_family(mobject, n_tabs=0):
+ """For debugging purposes"""
+ print("\t" * n_tabs, mobject, id(mobject))
+ for submob in mobject.submobjects:
+ submob.print_family(n_tabs + 1)
+
+
+def get_submobject_index_labels(mobject, label_height=0.15):
+ labels = VGroup()
+ for n, submob in enumerate(mobject):
+ label = Integer(n)
+ label.set_height(label_height)
+ label.move_to(submob)
+ label.set_stroke(BLACK, 5, background=True)
+ labels.add(label)
+ return labels