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.pyindex 35175f9d6..22f1019cc 100644--- a/manim/animation/transform.py+++ b/manim/animation/transform.py@@ -44,7 +44,7 @@ from .. import configfrom ..animation.animation import Animationfrom ..constants import DEFAULT_POINTWISE_FUNCTION_RUN_TIME, DEGREES, OUTfrom ..mobject.mobject import Group, Mobject-from ..mobject.opengl_mobject import OpenGLMobject+from ..mobject.opengl_mobject import OpenGLGroup, OpenGLMobjectfrom ..utils.paths import path_along_arc, straight_pathfrom ..utils.rate_functions import smooth, squish_rate_func@@ -456,7 +456,11 @@ class FadeTransform(Transform):self.stretch = stretchself.dim_to_match = dim_to_matchmobject.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.pyindex 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, Optionalimport numpy as np+from .._config import configfrom ..mobject.mobject import Group, Mobject+from ..mobject.opengl_mobject import OpenGLGroup, OpenGLMobjectfrom ..mobject.svg.tex_mobject import MathTex+from ..mobject.types.opengl_vectorized_mobject import OpenGLVGroup, OpenGLVMobjectfrom ..mobject.types.vectorized_mobject import VGroup, VMobjectfrom .composition import AnimationGroupfrom .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 = VGroupelse: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