Change ImageMobject rendering mode to TRIANGLES

And add vertices
This commit is contained in:
Fuwuwuwu
2023-09-03 08:55:03 +08:00
committed by GitHub
parent d8428585f8
commit 7278095921

View File

@ -2,6 +2,7 @@ from __future__ import annotations
import numpy as np import numpy as np
from PIL import Image from PIL import Image
from moderngl import TRIANGLES
from manimlib.constants import DL, DR, UL, UR from manimlib.constants import DL, DR, UL, UR
from manimlib.mobject.mobject import Mobject from manimlib.mobject.mobject import Mobject
@ -24,6 +25,7 @@ class ImageMobject(Mobject):
('im_coords', np.float32, (2,)), ('im_coords', np.float32, (2,)),
('opacity', np.float32, (1,)), ('opacity', np.float32, (1,)),
] ]
render_primitive: int = TRIANGLES
def __init__( def __init__(
self, self,
@ -37,9 +39,9 @@ class ImageMobject(Mobject):
super().__init__(texture_paths={"Texture": self.image_path}, **kwargs) super().__init__(texture_paths={"Texture": self.image_path}, **kwargs)
def init_data(self) -> None: def init_data(self) -> None:
super().init_data(length=4) super().init_data(length=6)
self.data["point"][:] = [UL, DL, UR, DR] self.data["point"][:] = [UL, DL, UR, DR, UR, DL]
self.data["im_coords"][:] = [(0, 0), (0, 1), (1, 0), (1, 1)] self.data["im_coords"][:] = [(0, 0), (0, 1), (1, 0), (1, 1), (1, 0), (0, 1)]
self.data["opacity"][:] = self.opacity self.data["opacity"][:] = self.opacity
def init_points(self) -> None: def init_points(self) -> None: