debug.py 887 B

1234567891011121314151617181920212223242526272829303132
  1. from __future__ import annotations
  2. from manimlib.constants import BLACK
  3. from manimlib.logger import log
  4. from manimlib.mobject.numbers import Integer
  5. from manimlib.mobject.types.vectorized_mobject import VGroup
  6. from typing import TYPE_CHECKING
  7. if TYPE_CHECKING:
  8. from manimlib.mobject.mobject import Mobject
  9. def print_family(mobject: Mobject, n_tabs: int = 0) -> None:
  10. """For debugging purposes"""
  11. log.debug("\t" * n_tabs + str(mobject) + " " + str(id(mobject)))
  12. for submob in mobject.submobjects:
  13. print_family(submob, n_tabs + 1)
  14. def index_labels(
  15. mobject: Mobject,
  16. label_height: float = 0.15
  17. ) -> VGroup:
  18. labels = VGroup()
  19. for n, submob in enumerate(mobject):
  20. label = Integer(n)
  21. label.set_height(label_height)
  22. label.move_to(submob)
  23. label.set_backstroke(BLACK, 5)
  24. labels.add(label)
  25. return labels