mirror of
https://github.com/3b1b/manim.git
synced 2025-08-21 05:44:04 +00:00
Add Mobject.set_shape
This commit is contained in:
parent
abdcb64461
commit
15d8ebb572
1 changed files with 16 additions and 1 deletions
|
@ -48,7 +48,7 @@ from manimlib.utils.space_ops import rotation_matrix_transpose
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if 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
|
import numpy.typing as npt
|
||||||
from manimlib.typing import ManimColor, Vect3, Vect4, Vect3Array, UniformDict
|
from manimlib.typing import ManimColor, Vect3, Vect4, Vect3Array, UniformDict
|
||||||
from moderngl.context import Context
|
from moderngl.context import Context
|
||||||
|
@ -1168,6 +1168,21 @@ class Mobject(object):
|
||||||
self.set_depth(min_depth, **kwargs)
|
self.set_depth(min_depth, **kwargs)
|
||||||
return self
|
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):
|
def set_coord(self, value: float, dim: int, direction: Vect3 = ORIGIN):
|
||||||
curr = self.get_coord(dim, direction)
|
curr = self.get_coord(dim, direction)
|
||||||
shift_vect = np.zeros(self.dim)
|
shift_vect = np.zeros(self.dim)
|
||||||
|
|
Loading…
Add table
Reference in a new issue