mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Add Mobject.replicate
This commit is contained in:
parent
0d2d1b5c03
commit
17c2772b84
1 changed files with 6 additions and 3 deletions
|
@ -365,14 +365,17 @@ class Mobject(object):
|
|||
self.center()
|
||||
return self
|
||||
|
||||
def replicate(self, n):
|
||||
return self.get_group_class()(
|
||||
*(self.copy() for x in range(n))
|
||||
)
|
||||
|
||||
def get_grid(self, n_rows, n_cols, height=None, **kwargs):
|
||||
"""
|
||||
Returns a new mobject containing multiple copies of this one
|
||||
arranged in a grid
|
||||
"""
|
||||
grid = self.get_group_class()(
|
||||
*(self.copy() for n in range(n_rows * n_cols))
|
||||
)
|
||||
grid = self.replicate(n_rows * n_cols)
|
||||
grid.arrange_in_grid(n_rows, n_cols, **kwargs)
|
||||
if height is not None:
|
||||
grid.set_height(height)
|
||||
|
|
Loading…
Add table
Reference in a new issue