Add Mobject.set_shape

This commit is contained in:
Grant Sanderson
2023-01-30 11:53:15 -08:00
parent abdcb64461
commit 15d8ebb572

View File

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