Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Add OpenGL support to the new transform animations (#1340)

Mohammad Al-Fetyani51845f43d049
diff --git a/manim/animation/transform.py b/manim/animation/transform.py
index 35175f9d6..22f1019cc 100644
--- a/manim/animation/transform.py
+++ b/manim/animation/transform.py
@@ -44,7 +44,7 @@ from .. import config
from ..animation.animation import Animation
from ..constants import DEFAULT_POINTWISE_FUNCTION_RUN_TIME, DEGREES, OUT
from ..mobject.mobject import Group, Mobject
-from ..mobject.opengl_mobject import OpenGLMobject
+from ..mobject.opengl_mobject import OpenGLGroup, OpenGLMobject
from ..utils.paths import path_along_arc, straight_path
from ..utils.rate_functions import smooth, squish_rate_func
@@ -456,7 +456,11 @@ class FadeTransform(Transform):
self.stretch = stretch
self.dim_to_match = dim_to_match
mobject.save_state()
- super().__init__(Group(mobject, target_mobject.copy()), **kwargs)
+ if config["renderer"] == "opengl":
+ group = OpenGLGroup(mobject, target_mobject.copy())
+ else:
+ group = Group(mobject, target_mobject.copy())
+ super().__init__(group, **kwargs)
def begin(self):
"""Initial setup for the animation.
diff --git a/manim/animation/transform_matching_parts.py b/manim/animation/transform_matching_parts.py
index 45133ad1f..2de9dcb5a 100644
--- a/manim/animation/transform_matching_parts.py
+++ b/manim/animation/transform_matching_parts.py
@@ -7,8 +7,11 @@ from typing import List, Optional
import numpy as np
+from .._config import config
from ..mobject.mobject import Group, Mobject
+from ..mobject.opengl_mobject import OpenGLGroup, OpenGLMobject
from ..mobject.svg.tex_mobject import MathTex
+from ..mobject.types.opengl_vectorized_mobject import OpenGLVGroup, OpenGLVMobject
from ..mobject.types.vectorized_mobject import VGroup, VMobject
from .composition import AnimationGroup
from .fading import FadeInFromPoint, FadeOutToPoint
@@ -70,7 +73,11 @@ class TransformMatchingAbstractBase(AnimationGroup):
):
assert type(mobject) is type(target_mobject)
- if isinstance(mobject, VMobject):
+ if isinstance(mobject, OpenGLVMobject):
+ group_type = OpenGLVGroup
+ elif isinstance(mobject, OpenGLMobject):
+ group_type = OpenGLGroup
+ elif isinstance(mobject, VMobject):
group_type = VGroup
else:
group_type = Group
@@ -135,7 +142,10 @@ class TransformMatchingAbstractBase(AnimationGroup):
for sm in self.get_mobject_parts(mobject):
key = self.get_mobject_key(sm)
if key not in shape_map:
- shape_map[key] = VGroup()
+ if config["renderer"] == "opengl":
+ shape_map[key] = OpenGLVGroup()
+ else:
+ shape_map[key] = VGroup()
shape_map[key].add(sm)
return shape_map