3b1b-manim/manimlib/utils/debug.py

33 lines
900 B
Python
Raw Normal View History

from __future__ import annotations
from manimlib.constants import BLACK
2022-04-12 19:19:59 +08:00
from manimlib.logger import log
from manimlib.mobject.numbers import Integer
from manimlib.mobject.types.vectorized_mobject import VGroup
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from manimlib.mobject.mobject import Mobject
def print_family(mobject: Mobject, n_tabs: int = 0) -> None:
"""For debugging purposes"""
2021-10-07 17:37:10 +08:00
log.debug("\t" * n_tabs + str(mobject) + " " + str(id(mobject)))
for submob in mobject.submobjects:
2019-12-17 09:37:59 -08:00
print_family(submob, n_tabs + 1)
def index_labels(
mobject: Mobject,
label_height: float = 0.15
) -> VGroup:
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