MCPcopy
hub / github.com/ManimCommunity/manim / add

Method add

manim/scene/scene.py:479–521  ·  view source on GitHub ↗

Mobjects will be displayed, from background to foreground in the order with which they are added. Parameters --------- *mobjects Mobjects to add. Returns ------- Scene The same scene after adding the Mobjects

(self, *mobjects: Mobject | OpenGLMobject)

Source from the content-addressed store, hash-verified

477 )
478
479 def add(self, *mobjects: Mobject | OpenGLMobject) -> Self:
480 """
481 Mobjects will be displayed, from background to
482 foreground in the order with which they are added.
483
484 Parameters
485 ---------
486 *mobjects
487 Mobjects to add.
488
489 Returns
490 -------
491 Scene
492 The same scene after adding the Mobjects in.
493
494 """
495 if config.renderer == RendererType.OPENGL:
496 new_mobjects = []
497 new_meshes: list[Object3D] = []
498 for mobject_or_mesh in mobjects:
499 if isinstance(mobject_or_mesh, Object3D):
500 new_meshes.append(mobject_or_mesh)
501 else:
502 new_mobjects.append(mobject_or_mesh)
503 self.remove(*new_mobjects) # type: ignore[arg-type]
504 self.mobjects += new_mobjects # type: ignore[arg-type]
505 self.remove(*new_meshes) # type: ignore[arg-type]
506 self.meshes += new_meshes
507 else:
508 assert config.renderer == RendererType.CAIRO
509 new_and_foreground_mobjects: list[Mobject] = [
510 *mobjects, # type: ignore[list-item]
511 *self.foreground_mobjects,
512 ]
513 self.restructure_mobjects(to_remove=new_and_foreground_mobjects)
514 self.mobjects += new_and_foreground_mobjects
515 if self.moving_mobjects:
516 self.restructure_mobjects(
517 to_remove=new_and_foreground_mobjects,
518 mobject_list_name="moving_mobjects",
519 )
520 self.moving_mobjects += new_and_foreground_mobjects
521 return self
522
523 def add_mobjects_from_animations(self, animations: list[Animation]) -> None:
524 curr_mobjects = self.get_mobject_family_members()

Callers 15

test_scene_add_removeFunction · 0.95
test_replaceFunction · 0.95
test_reproducible_sceneFunction · 0.95
test_scene_add_removeFunction · 0.95
bring_to_frontMethod · 0.95
constructMethod · 0.45
constructMethod · 0.45

Calls 3

removeMethod · 0.95
restructure_mobjectsMethod · 0.95
appendMethod · 0.45

Tested by 15

test_scene_add_removeFunction · 0.76
test_replaceFunction · 0.76
test_reproducible_sceneFunction · 0.76
test_scene_add_removeFunction · 0.76
constructMethod · 0.36
constructMethod · 0.36
test_cellFunction · 0.36
test_zoomFunction · 0.36
test_vmobject_addFunction · 0.36