Element Management
The Element management functions of
Scene object is to manage the
Mobject objects of
Scene object. The Element management functions are
- def add(self, *mobjects)
- def remove(self, *mobjects)
- def add_mobjects_among(self, values)
- def add_foreground_mobjects(self, *mobjects)
- def add_foreground_mobject(self, mobject)
- def remove_foreground_mobjects(self, *to_remove)
- def remove_foreground_mobject(self, mobject)
- def clear(self)
def Remove_foreground_mobjects(self, *mobjects)
Remove the priority of one or more
Mobject objects by reconstructing the specified
Mobject from the priority casting list of
Scene object back into the casting list of
Scene object according to the existing position or layer in the combined list. In other words, the priority of specified
Mobjects are stoped by moving from the priority casting list to the foreground of the casting list.
last updated 28Dec2019
Example Scene.remove_foreground_mobjects
Example of Scene.remove_foreground_mobjects.
Code Scene.remove_foreground_mobjects
# folder/file: tut/manim_scene_remove_foreground_mobjects_001a.py
from manimlib.scene.scene import Scene
from manimlib.mobject.geometry import Circle
from manimlib.mobject.geometry import Square
class manim_scene_remove_foreground_mobjects_001a(Scene):
def construct(self):
temp=Square()
temp1=Circle(stroke_width=10)
temp2=Square(color="#FFFF00",stroke_width=10,side_length=1.8)
temp3=Square(fill_opacity=1)
temp4=Square(color="#22FF00",fill_opacity=1,side_length=1.5)
temp5=Circle(color="#22FF00",radius=1.1,stroke_width=10)
self.add(temp)
self.add_foreground_mobjects(temp2,temp1)
self.add(temp3)
self.remove_foreground_mobjects(temp1,temp)
self.add(temp4,temp5)
Output Scene.remove_foreground_mobjects
def Remove_foreground_mobject(self, mobject)
Same function as
remove_foreground_mobjects, but remove only one
Mobject object from the priority casting list of
Scene object back into the casting list.
last updated 28Dec2019
Example Scene.remove_foreground_mobject
Example of Scene.remove_foreground_mobject.
Code Scene.remove_foreground_mobject
# folder/file: tut/manim_scene_remove_foreground_mobject_001a.py
from manimlib.scene.scene import Scene
from manimlib.mobject.geometry import Circle
from manimlib.mobject.geometry import Square
class manim_scene_remove_foreground_mobject_001a(Scene):
def construct(self):
temp=Square()
temp1=Circle(stroke_width=10)
temp2=Square(color="#FFFF00",stroke_width=10,side_length=1.8)
temp3=Square(fill_opacity=1)
temp4=Square(color="#22FF00",fill_opacity=1,side_length=1.5)
temp5=Circle(color="#22FF00",radius=1.1,stroke_width=10)
self.add(temp)
self.add_foreground_mobjects(temp2,temp1)
self.add(temp3)
self.remove_foreground_mobject(temp1)
self.remove_foreground_mobject(temp)
self.add(temp4,temp5)
Output Scene.remove_foreground_mobject
def clear(self)
Clear all
Mobject objects in both the priority casting list and casting list of
Scene object. In other words, all element in both the priority casting list and casting list of
Scene object are removed.
last updated 28Dec2019
Example Scene.clear
Example of Scene.clear.
Code Scene.clear
# folder/file: tut/manim_scene_clear_001a.py
from manimlib.scene.scene import Scene
from manimlib.mobject.geometry import Circle
from manimlib.mobject.geometry import Square
class manim_scene_clear_001a(Scene):
def construct(self):
temp=Square()
temp1=Circle(stroke_width=10)
temp2=Square(color="#FFFF00",stroke_width=10,side_length=1.8)
temp3=Square(fill_opacity=1)
self.add(temp)
self.add_foreground_mobjects(temp1,temp2)
self.add(temp3)
self.clear()
Output Scene.clear