diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index d1fb0410..32a113f7 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -48,7 +48,7 @@ from manimlib.utils.space_ops import rotation_matrix_transpose from typing import TYPE_CHECKING if TYPE_CHECKING: - from typing import Callable, Iterable, Union, Tuple + from typing import Callable, Iterable, Union, Tuple, Optional import numpy.typing as npt from manimlib.typing import ManimColor, Vect3, Vect4, Vect3Array, UniformDict from moderngl.context import Context @@ -1168,6 +1168,21 @@ class Mobject(object): self.set_depth(min_depth, **kwargs) return self + def set_shape( + self, + width: Optional[float] = None, + height: Optional[float] = None, + depth: Optional[float] = None, + **kwargs + ): + if width is not None: + self.set_width(width, stretch=True, **kwargs) + if height is not None: + self.set_height(height, stretch=True, **kwargs) + if depth is not None: + self.set_depth(depth, stretch=True, **kwargs) + return self + def set_coord(self, value: float, dim: int, direction: Vect3 = ORIGIN): curr = self.get_coord(dim, direction) shift_vect = np.zeros(self.dim)