diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index d93fd180..b5e89fc0 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -82,6 +82,14 @@ class Mobject(object): def __str__(self): return self.__class__.__name__ + def __add__(self, other : 'Mobject') -> 'Mobject': + assert(isinstance(other, Mobject)) + return self.get_group_class()(self, other) + + def __mul__(self, other : 'int') -> 'Mobject': + assert(isinstance(other, int)) + return self.replicate(other) + def init_data(self): self.data = { "points": np.zeros((0, 3)), @@ -1609,6 +1617,10 @@ class Group(Mobject): raise Exception("All submobjects must be of type Mobject") Mobject.__init__(self, **kwargs) self.add(*mobjects) + + def __add__(self, other : 'Mobject' or 'Group'): + assert(isinstance(other, Mobject)) + return self.add(other) class Point(Mobject): diff --git a/manimlib/mobject/types/vectorized_mobject.py b/manimlib/mobject/types/vectorized_mobject.py index 48d2902c..9661d9a6 100644 --- a/manimlib/mobject/types/vectorized_mobject.py +++ b/manimlib/mobject/types/vectorized_mobject.py @@ -999,6 +999,10 @@ class VGroup(VMobject): raise Exception("All submobjects must be of type VMobject") super().__init__(**kwargs) self.add(*vmobjects) + + def __add__(self:'VGroup', other : 'VMobject' or 'VGroup'): + assert(isinstance(other, VMobject)) + return self.add(other) class VectorizedPoint(Point, VMobject):