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