Skip to content

Commit

Permalink
Move OpenGL Files
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Jun 24, 2024
1 parent d54ef60 commit 2bbd5b0
Show file tree
Hide file tree
Showing 3 changed files with 467 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

__all__ = [
"OpenGLImageMobject",
"ImageMobject",
]

from pathlib import Path
Expand All @@ -10,13 +10,13 @@
from PIL import Image
from PIL.Image import Resampling

from manim.mobject.opengl.opengl_surface import OpenGLSurface, OpenGLTexturedSurface
from manim.mobject.opengl.opengl_surface import Surface, TexturedSurface
from manim.utils.images import get_full_raster_image_path

__all__ = ["OpenGLImageMobject"]
__all__ = ["ImageMobject"]


class OpenGLImageMobject(OpenGLTexturedSurface):
class ImageMobject(TexturedSurface):
def __init__(
self,
filename_or_array: str | Path | np.ndarray,
Expand Down Expand Up @@ -45,7 +45,7 @@ def __init__(
if width is None:
width = height * self.size[0] / self.size[1]

surface = OpenGLSurface(
surface = Surface(
lambda u, v: np.array([u, v, 0]),
[-width / 2, width / 2],
[-height / 2, height / 2],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from __future__ import annotations

__all__ = ["OpenGLPMobject", "OpenGLPGroup", "OpenGLPMPoint"]
__all__ = ["PMobject", "PGroup", "PMPoint"]

import moderngl
import numpy as np

from manim.constants import *
from manim.mobject.opengl.opengl_mobject import OpenGLMobject
from manim.mobject.mobject import Mobject
from manim.utils.bezier import interpolate
from manim.utils.color import BLACK, WHITE, YELLOW, color_gradient, color_to_rgba
from manim.utils.config_ops import _Uniforms
from manim.utils.iterables import resize_with_interpolation

__all__ = ["OpenGLPMobject", "OpenGLPGroup", "OpenGLPMPoint"]
__all__ = ["PMobject", "PGroup", "PMPoint"]


class OpenGLPMobject(OpenGLMobject):
class PMobject(Mobject):
shader_folder = "true_dot"
# Scale for consistency with cairo units
OPENGL_POINT_RADIUS_SCALE_FACTOR = 0.01
Expand All @@ -32,7 +32,7 @@ def __init__(
self.stroke_width = stroke_width
super().__init__(color=color, render_primitive=render_primitive, **kwargs)
self.point_radius = (
self.stroke_width * OpenGLPMobject.OPENGL_POINT_RADIUS_SCALE_FACTOR
self.stroke_width * PMobject.OPENGL_POINT_RADIUS_SCALE_FACTOR
)

def reset_points(self):
Expand Down Expand Up @@ -159,12 +159,12 @@ def get_shader_data(self):

@staticmethod
def get_mobject_type_class():
return OpenGLPMobject
return PMobject


class OpenGLPGroup(OpenGLPMobject):
class PGroup(PMobject):
def __init__(self, *pmobs, **kwargs):
if not all(isinstance(m, OpenGLPMobject) for m in pmobs):
if not all(isinstance(m, PMobject) for m in pmobs):
raise Exception("All submobjects must be of type OpenglPMObject")
super().__init__(**kwargs)
self.add(*pmobs)
Expand All @@ -175,7 +175,7 @@ def fade_to(self, color, alpha, family=True):
mob.fade_to(color, alpha, family)


class OpenGLPMPoint(OpenGLPMobject):
class PMPoint(PMobject):
def __init__(self, location=ORIGIN, stroke_width=4.0, **kwargs):
self.location = location
super().__init__(stroke_width=stroke_width, **kwargs)
Expand Down
Loading

0 comments on commit 2bbd5b0

Please sign in to comment.