A community-maintained Python framework for creating mathematical animations.
Metaclass compatibility for `coordinate_system.py`, `Code` and `ParametricSurface` (#1735)
Laith Bahodic7ced02196fb
diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.pyindex a3b58b97f..a5ae1f45e 100644--- a/manim/mobject/coordinate_systems.py+++ b/manim/mobject/coordinate_systems.py@@ -17,6 +17,8 @@ from typing import Callable, Iterable, Optional, Sequence, Tuple, Unionimport numpy as npfrom colour import Color+from manim.mobject.opengl_compatibility import ConvertToOpenGL+from .. import configfrom ..constants import *from ..mobject.functions import ParametricFunction@@ -1018,7 +1020,7 @@ class CoordinateSystem:return T_label_group-class Axes(VGroup, CoordinateSystem):+class Axes(VGroup, CoordinateSystem, metaclass=ConvertToOpenGL):"""Creates a set of axes.Parameters@@ -1359,8 +1361,9 @@ class ThreeDAxes(Axes):self.add(z_axis)self.z_axis = z_axis- self.add_3d_pieces()- self.set_axis_shading()+ if not config.renderer == "opengl":+ self.add_3d_pieces()+ self.set_axis_shading()def add_3d_pieces(self):for axis in self.axes:diff --git a/manim/mobject/svg/code_mobject.py b/manim/mobject/svg/code_mobject.pyindex 3d02f0a92..7acbb5794 100644--- a/manim/mobject/svg/code_mobject.py+++ b/manim/mobject/svg/code_mobject.py@@ -170,13 +170,12 @@ class Code(VGroup):generate_html_file=False,**kwargs,):- VGroup.__init__(- self,+ super().__init__(stroke_width=stroke_width,- background_stroke_color=background_stroke_color,- background_stroke_width=background_stroke_width,**kwargs,)+ self.background_stroke_color = background_stroke_color+ self.background_stroke_width = background_stroke_widthself.tab_width = tab_widthself.line_spacing = line_spacingself.scale_factor = scale_factor@@ -264,12 +263,11 @@ class Code(VGroup):self.background_mobject.shift(foreground.get_center())self.background_mobject.shift(UP * x)if self.insert_line_no:- VGroup.__init__(- self, self.background_mobject, self.line_numbers, self.code, **kwargs+ super().__init__(+ self.background_mobject, self.line_numbers, self.code, **kwargs)else:- VGroup.__init__(- self,+ super().__init__(self.background_mobject,Dot(fill_opacity=0, stroke_opacity=0),self.code,diff --git a/manim/mobject/three_dimensions.py b/manim/mobject/three_dimensions.pyindex 5bf4e6a3c..6856adf20 100644--- a/manim/mobject/three_dimensions.py+++ b/manim/mobject/three_dimensions.py@@ -16,6 +16,8 @@ __all__ = [import numpy as np+from manim.mobject.opengl_compatibility import ConvertToOpenGL+from ..constants import *from ..mobject.geometry import Circle, Squarefrom ..mobject.mobject import *@@ -26,7 +28,7 @@ from ..utils.iterables import tuplifyfrom ..utils.space_ops import normalize, z_to_vector-class ThreeDVMobject(VMobject):+class ThreeDVMobject(VMobject, metaclass=ConvertToOpenGL):def __init__(self, shade_in_3d=True, **kwargs):super().__init__(shade_in_3d=shade_in_3d, **kwargs)@@ -74,7 +76,7 @@ class ParametricSurface(VGroup):pre_function_handle_to_anchor_scale_factor=0.00001,**kwargs):- VGroup.__init__(self, **kwargs)+ super().__init__(**kwargs)self.u_min = u_minself.u_max = u_maxself.v_min = v_min