Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Let :class:`~.Create` work on :class:`~.OpenGLSurface` (#1775)

Darylgolden5dc5d38724ea
diff --git a/manim/animation/creation.py b/manim/animation/creation.py
index ea3b45f05..0fbf03c5e 100644
--- a/manim/animation/creation.py
+++ b/manim/animation/creation.py
@@ -92,6 +92,7 @@ if TYPE_CHECKING:
from ..animation.animation import Animation
from ..animation.composition import Succession
from ..mobject.mobject import Group, Mobject
+from ..mobject.types.opengl_surface import OpenGLSurface
from ..mobject.types.opengl_vectorized_mobject import OpenGLVMobject
from ..mobject.types.vectorized_mobject import VMobject
from ..utils.bezier import integer_interpolate
@@ -113,9 +114,12 @@ class ShowPartial(Animation):
"""
- def __init__(self, mobject: Union[Mobject, OpenGLVMobject, None], **kwargs):
- if not isinstance(mobject, (VMobject, OpenGLVMobject)):
- raise TypeError("This Animation only works on vectorized mobjects")
+ def __init__(
+ self, mobject: Union[VMobject, OpenGLVMobject, OpenGLSurface, None], **kwargs
+ ):
+ pointwise = getattr(mobject, "pointwise_become_partial", None)
+ if not callable(pointwise):
+ raise NotImplementedError("This animation is not defined for this Mobject.")
super().__init__(mobject, **kwargs)
def interpolate_submobject(
@@ -158,7 +162,7 @@ class Create(ShowPartial):
def __init__(
self,
- mobject: Union[VMobject, OpenGLVMobject],
+ mobject: Union[VMobject, OpenGLVMobject, OpenGLSurface],
lag_ratio: float = 1.0,
**kwargs,
) -> None:
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py
index 3092ef9f9..a80d97c7a 100644
--- a/manim/mobject/mobject.py
+++ b/manim/mobject/mobject.py
@@ -2609,9 +2609,6 @@ class Mobject:
def interpolate_color(self, mobject1, mobject2, alpha):
raise NotImplementedError("Please override in a child class.")
- def pointwise_become_partial(self, mobject, a, b):
- raise NotImplementedError("Please override in a child class.")
-
def become(self, mobject: "Mobject", copy_submobjects: bool = True):
"""Edit points, colors and submobjects to be identical
to another :class:`~.Mobject`