Merge branch 'master' of github.com:3b1b/manim into video-work

This commit is contained in:
Grant Sanderson
2021-11-01 13:18:09 -07:00
2 changed files with 16 additions and 0 deletions

View File

@ -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):

View File

@ -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):