Kill CONFIG in mobject.py

This commit is contained in:
Grant Sanderson 2022-12-15 09:18:22 -08:00
parent a817364a0e
commit 133ac8bb26

View file

@ -47,48 +47,58 @@ 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, Sequence, Union from typing import Callable, Iterable, Sequence, Union, Tuple
import numpy.typing as npt import numpy.typing as npt
TimeBasedUpdater = Callable[["Mobject", float], None] TimeBasedUpdater = Callable[["Mobject", float], None]
NonTimeUpdater = Callable[["Mobject"], None] NonTimeUpdater = Callable[["Mobject"], None]
Updater = Union[TimeBasedUpdater, NonTimeUpdater] Updater = Union[TimeBasedUpdater, NonTimeUpdater]
from manimlib.constants import ManimColor
np_vector = np.ndarray[int, np.dtype[np.float64]] from manimlib.constants import ManimColor, np_vector
class Mobject(object): class Mobject(object):
""" """
Mathematical Object Mathematical Object
""" """
CONFIG = { dim: int = 3
"color": WHITE, shader_folder: str = ""
"opacity": 1, render_primitive: int = moderngl.TRIANGLE_STRIP
"dim": 3, # TODO, get rid of this # Must match in attributes of vert shader
# Lighting parameters shader_dtype: Sequence[Tuple[str, type, Tuple[int]]] = [
# ... ('point', np.float32, (3,)),
# Larger reflectiveness makes things brighter when facing the light ]
"reflectiveness": 0.0, depth_test: bool = False
# Larger shadow makes faces opposite the light darker
"shadow": 0.0,
# Makes parts bright where light gets reflected toward the camera
"gloss": 0.0,
# For shaders
"shader_folder": "",
"render_primitive": moderngl.TRIANGLE_STRIP,
"texture_paths": None,
"depth_test": False,
# If true, the mobject will not get rotated according to camera position
"is_fixed_in_frame": False,
# Must match in attributes of vert shader
"shader_dtype": [
('point', np.float32, (3,)),
],
}
def __init__(self, **kwargs): CONFIG = {} # Need to delete
digest_config(self, kwargs)
def __init__(
self,
color: ManimColor = WHITE,
opacity: float = 1.0,
# Larger reflectiveness makes things brighter when facing the light
reflectiveness: float = 0.0,
# Larger shadow makes faces opposite the light darker
shadow: float = 0.0,
# Makes parts bright where light gets reflected toward the camera
gloss: float = 0.0,
# For shaders
texture_paths: str | Sequence[str] | None = None,
# If true, the mobject will not get rotated according to camera position
is_fixed_in_frame: bool = False,
**kwargs
):
self.color = color
self.opacity = opacity
self.reflectiveness = reflectiveness
self.shadow = shadow
self.gloss = gloss
self.texture_paths = texture_paths
self.is_fixed_in_frame = is_fixed_in_frame
digest_config(self, kwargs) # Need to delete
# Internal state
self.submobjects: list[Mobject] = [] self.submobjects: list[Mobject] = []
self.parents: list[Mobject] = [] self.parents: list[Mobject] = []
self.family: list[Mobject] = [self] self.family: list[Mobject] = [self]
@ -2017,13 +2027,16 @@ class Group(Mobject):
class Point(Mobject): class Point(Mobject):
CONFIG = { def __init__(
"artificial_width": 1e-6, self,
"artificial_height": 1e-6, location: np_vector = ORIGIN,
} artificial_width: float = 1e-6,
artificial_height: float = 1e-6,
def __init__(self, location: npt.ArrayLike = ORIGIN, **kwargs): **kwargs
Mobject.__init__(self, **kwargs) ):
self.artificial_width = artificial_width
self.artificial_height = artificial_height
super().__init__(**kwargs)
self.set_location(location) self.set_location(location)
def get_width(self) -> float: def get_width(self) -> float: