Skip to content

armgit / manim

Public Imported from GitHub
0

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.py
index 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, Union
import numpy as np
from colour import Color
+from manim.mobject.opengl_compatibility import ConvertToOpenGL
+
from .. import config
from ..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.py
index 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_width
self.tab_width = tab_width
self.line_spacing = line_spacing
self.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.py
index 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, Square
from ..mobject.mobject import *
@@ -26,7 +28,7 @@ from ..utils.iterables import tuplify
from ..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_min
self.u_max = u_max
self.v_min = v_min