2020-02-20 16:50:13 -08:00
|
|
|
import time
|
|
|
|
|
2019-12-06 17:10:00 -08:00
|
|
|
from manimlib.constants import BLACK
|
|
|
|
from manimlib.mobject.numbers import Integer
|
|
|
|
from manimlib.mobject.types.vectorized_mobject import VGroup
|
2021-10-07 17:37:10 +08:00
|
|
|
from manimlib.logger import log
|
2019-12-06 17:10:00 -08:00
|
|
|
|
|
|
|
|
|
|
|
def print_family(mobject, n_tabs=0):
|
|
|
|
"""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
|
|
|
|
|
|
|
|
2020-02-27 17:16:10 +00:00
|
|
|
def index_labels(mobject, label_height=0.15):
|
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
|
2020-02-20 16:50:13 -08:00
|
|
|
|
|
|
|
|
|
|
|
def get_runtime(func):
|
|
|
|
now = time.time()
|
|
|
|
func()
|
|
|
|
return time.time() - now
|