Skip to content

Commit

Permalink
Add set_max_width, set_max_height, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
3b1b committed Aug 19, 2021
1 parent 56df154 commit 3bb8f3f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions manimlib/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,21 @@ def set_height(self, height, stretch=False, **kwargs):
def set_depth(self, depth, stretch=False, **kwargs):
return self.rescale_to_fit(depth, 2, stretch=stretch, **kwargs)

def set_max_width(self, max_width, **kwargs):
if self.get_width() > max_width:
self.set_width(max_width, **kwargs)
return self

def set_max_height(self, max_height, **kwargs):
if self.get_height() > max_height:
self.set_height(max_height, **kwargs)
return self

def set_max_depth(self, max_depth, **kwargs):
if self.get_depth() > max_depth:
self.set_depth(max_depth, **kwargs)
return self

def set_coord(self, value, dim, direction=ORIGIN):
curr = self.get_coord(dim, direction)
shift_vect = np.zeros(self.dim)
Expand Down

0 comments on commit 3bb8f3f

Please sign in to comment.