def __init__(self, mobject_or_chars): TextMobject.__init__(self) if mobject_or_chars == None or (isinstance(mobject_or_chars, Mobject) and mobject_or_chars.name == "Mobject"): mobject = Mobject() elif isinstance(mobject_or_chars, (list)): mobject = ImageMobject(mobject_or_chars[0]) self.add(mobject) self = mobject.copy() elif isinstance(mobject_or_chars, Mobject) and mobject_or_chars.name == "ImageMobject": mobject = mobject_or_chars self.add(mobject) self = mobject_or_chars[0].copy() else: if isinstance(mobject_or_chars, str): #mobject =MTex(mobject_or_chars) mobject = TextMobject(mobject_or_chars) elif isinstance(mobject_or_chars, int): mobject = Integer(mobject_or_chars) elif isinstance(mobject_or_chars, float): mobject = DecimalNumber(mobject_or_chars) elif isinstance(mobject_or_chars, (tuple)): mobject = TextMobject(*mobject_or_chars) else: mobject = mobject_or_chars self.become(mobject) self.name = mobject.name self.__class__ = mobject.__class__
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
def index_labels(mobject: Mobject | np.ndarray, 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
def combinationMobject(n, k): return Integer(choose(n, k))