From 84e7bdb2b1f41929dada735094eccc9fc2cdc65c Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Fri, 6 Dec 2019 17:10:00 -0800 Subject: [PATCH] Added a couple helpful debugging functions --- manimlib/imports.py | 1 + manimlib/utils/debug.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 manimlib/utils/debug.py diff --git a/manimlib/imports.py b/manimlib/imports.py index b6fd097b..23c1498e 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 00000000..b01ee2bf --- /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