Added a couple helpful debugging functions

This commit is contained in:
Grant Sanderson
2019-12-06 17:10:00 -08:00
parent b7cb9aa938
commit 84e7bdb2b1
2 changed files with 22 additions and 0 deletions

View File

@ -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 *

21
manimlib/utils/debug.py Normal file
View File

@ -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