Kill CONFIG in ImageMobject

This commit is contained in:
Grant Sanderson 2022-12-15 09:56:01 -08:00
parent 98c53151ad
commit 3a65eb4d2c

View file

@ -9,27 +9,31 @@ from manimlib.utils.bezier import inverse_interpolate
from manimlib.utils.images import get_full_raster_image_path
from manimlib.utils.iterables import listify
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Sequence, Tuple
from manimlib.constants import ManimColor, np_vector
class ImageMobject(Mobject):
CONFIG = {
"height": 4,
"opacity": 1,
"shader_folder": "image",
"shader_dtype": [
('point', np.float32, (3,)),
('im_coords', np.float32, (2,)),
('opacity', np.float32, (1,)),
]
}
shader_folder: str = "image"
shader_dtype: Sequence[Tuple[str, type, Tuple[int]]] = [
('point', np.float32, (3,)),
('im_coords', np.float32, (2,)),
('opacity', np.float32, (1,)),
]
def __init__(self, filename: str, **kwargs):
self.set_image_path(get_full_raster_image_path(filename))
super().__init__(**kwargs)
def set_image_path(self, path: str) -> None:
self.path = path
self.image = Image.open(path)
self.texture_paths = {"Texture": path}
def __init__(
self,
filename: str,
height: float = 4.0,
**kwargs
):
self.height = height
self.image_path = get_full_raster_image_path(filename)
self.image = Image.open(self.image_path)
super().__init__(texture_paths={"Texture": self.image_path}, **kwargs)
def init_data(self) -> None:
self.data = {
@ -51,7 +55,7 @@ class ImageMobject(Mobject):
def set_color(self, color, opacity=None, recurse=None):
return self
def point_to_rgb(self, point: np.ndarray) -> np.ndarray:
def point_to_rgb(self, point: np_vector) -> np_vector:
x0, y0 = self.get_corner(UL)[:2]
x1, y1 = self.get_corner(DR)[:2]
x_alpha = inverse_interpolate(x0, x1, point[0])