mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Kill CONFIG in ImageMobject
This commit is contained in:
parent
98c53151ad
commit
3a65eb4d2c
1 changed files with 23 additions and 19 deletions
|
@ -9,27 +9,31 @@ from manimlib.utils.bezier import inverse_interpolate
|
||||||
from manimlib.utils.images import get_full_raster_image_path
|
from manimlib.utils.images import get_full_raster_image_path
|
||||||
from manimlib.utils.iterables import listify
|
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):
|
class ImageMobject(Mobject):
|
||||||
CONFIG = {
|
shader_folder: str = "image"
|
||||||
"height": 4,
|
shader_dtype: Sequence[Tuple[str, type, Tuple[int]]] = [
|
||||||
"opacity": 1,
|
('point', np.float32, (3,)),
|
||||||
"shader_folder": "image",
|
('im_coords', np.float32, (2,)),
|
||||||
"shader_dtype": [
|
('opacity', np.float32, (1,)),
|
||||||
('point', np.float32, (3,)),
|
]
|
||||||
('im_coords', np.float32, (2,)),
|
|
||||||
('opacity', np.float32, (1,)),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, filename: str, **kwargs):
|
def __init__(
|
||||||
self.set_image_path(get_full_raster_image_path(filename))
|
self,
|
||||||
super().__init__(**kwargs)
|
filename: str,
|
||||||
|
height: float = 4.0,
|
||||||
def set_image_path(self, path: str) -> None:
|
**kwargs
|
||||||
self.path = path
|
):
|
||||||
self.image = Image.open(path)
|
self.height = height
|
||||||
self.texture_paths = {"Texture": path}
|
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:
|
def init_data(self) -> None:
|
||||||
self.data = {
|
self.data = {
|
||||||
|
@ -51,7 +55,7 @@ class ImageMobject(Mobject):
|
||||||
def set_color(self, color, opacity=None, recurse=None):
|
def set_color(self, color, opacity=None, recurse=None):
|
||||||
return self
|
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]
|
x0, y0 = self.get_corner(UL)[:2]
|
||||||
x1, y1 = self.get_corner(DR)[:2]
|
x1, y1 = self.get_corner(DR)[:2]
|
||||||
x_alpha = inverse_interpolate(x0, x1, point[0])
|
x_alpha = inverse_interpolate(x0, x1, point[0])
|
||||||
|
|
Loading…
Add table
Reference in a new issue