"""Utilities for working with mobjects."""from__future__importannotations__all__=["get_mobject_class","get_point_mobject_class","get_vectorized_mobject_class",]from.._configimportconfigfrom..constantsimportRendererTypefrom.mobjectimportMobjectfrom.opengl.opengl_mobjectimportOpenGLMobjectfrom.opengl.opengl_point_cloud_mobjectimportOpenGLPMobjectfrom.opengl.opengl_vectorized_mobjectimportOpenGLVMobjectfrom.types.point_cloud_mobjectimportPMobjectfrom.types.vectorized_mobjectimportVMobject
[docs]defget_mobject_class()->type:"""Gets the base mobject class, depending on the currently active renderer. .. NOTE:: This method is intended to be used in the code base of Manim itself or in plugins where code should work independent of the selected renderer. Examples -------- The function has to be explicitly imported. We test that the name of the returned class is one of the known mobject base classes:: >>> from manim.mobject.utils import get_mobject_class >>> get_mobject_class().__name__ in ['Mobject', 'OpenGLMobject'] True """ifconfig.renderer==RendererType.CAIRO:returnMobjectifconfig.renderer==RendererType.OPENGL:returnOpenGLMobjectraiseNotImplementedError("Base mobjects are not implemented for the active renderer.")
[docs]defget_vectorized_mobject_class()->type:"""Gets the vectorized mobject class, depending on the currently active renderer. .. NOTE:: This method is intended to be used in the code base of Manim itself or in plugins where code should work independent of the selected renderer. Examples -------- The function has to be explicitly imported. We test that the name of the returned class is one of the known mobject base classes:: >>> from manim.mobject.utils import get_vectorized_mobject_class >>> get_vectorized_mobject_class().__name__ in ['VMobject', 'OpenGLVMobject'] True """ifconfig.renderer==RendererType.CAIRO:returnVMobjectifconfig.renderer==RendererType.OPENGL:returnOpenGLVMobjectraiseNotImplementedError("Vectorized mobjects are not implemented for the active renderer.")
[docs]defget_point_mobject_class()->type:"""Gets the point cloud mobject class, depending on the currently active renderer. .. NOTE:: This method is intended to be used in the code base of Manim itself or in plugins where code should work independent of the selected renderer. Examples -------- The function has to be explicitly imported. We test that the name of the returned class is one of the known mobject base classes:: >>> from manim.mobject.utils import get_point_mobject_class >>> get_point_mobject_class().__name__ in ['PMobject', 'OpenGLPMobject'] True """ifconfig.renderer==RendererType.CAIRO:returnPMobjectifconfig.renderer==RendererType.OPENGL:returnOpenGLPMobjectraiseNotImplementedError("Point cloud mobjects are not implemented for the active renderer.")