Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Add parametric function support to OpenGLSurface (#1151)

Mohammad Al-Fetyanie4d539f0d505
diff --git a/manim/mobject/types/opengl_surface.py b/manim/mobject/types/opengl_surface.py
index 80acda9b5..60253f0ef 100644
--- a/manim/mobject/types/opengl_surface.py
+++ b/manim/mobject/types/opengl_surface.py
@@ -22,6 +22,7 @@ class OpenGLSurface(OpenGLMobject):
def __init__(
self,
+ uv_func=None,
u_range=None,
v_range=None,
# Resolution counts number of points sampled, which for
@@ -41,6 +42,7 @@ class OpenGLSurface(OpenGLMobject):
shader_folder=None,
**kwargs
):
+ self.passed_uv_func = uv_func
self.u_range = u_range if u_range is not None else (0, 1)
self.v_range = v_range if v_range is not None else (0, 1)
# Resolution counts number of points sampled, which for
@@ -66,6 +68,8 @@ class OpenGLSurface(OpenGLMobject):
def uv_func(self, u, v):
# To be implemented in subclasses
+ if self.passed_uv_func:
+ return self.passed_uv_func(u, v)
return (u, v, 0.0)
def init_points(self):