mirror of
https://github.com/3b1b/manim.git
synced 2025-07-29 13:03:31 +08:00
fixed bug for reduce_across_dimension for mobs with empty submobs
This commit is contained in:
@ -467,6 +467,8 @@ class Mobject(Container):
|
||||
|
||||
# Background rectangle
|
||||
def add_background_rectangle(self, color=BLACK, opacity=0.75, **kwargs):
|
||||
# TODO, this does not behave well when the mobject has points,
|
||||
# since it gets displayed on top
|
||||
from mobject.shape_matchers import BackgroundRectangle
|
||||
self.background_rectangle = BackgroundRectangle(
|
||||
self, color=color,
|
||||
@ -621,13 +623,17 @@ class Mobject(Container):
|
||||
values = []
|
||||
values += [
|
||||
mob.reduce_across_dimension(points_func, reduce_func, dim)
|
||||
for mob in self.submobjects
|
||||
for mob in self.nonempty_submobjects()
|
||||
]
|
||||
try:
|
||||
return reduce_func(values)
|
||||
except:
|
||||
return 0
|
||||
|
||||
def nonempty_submobjects(self):
|
||||
return [submob for submob in self.submobjects
|
||||
if len(submob.submobjects) != 0 or len(submob.points) != 0]
|
||||
|
||||
def get_merged_array(self, array_attr):
|
||||
result = None
|
||||
for mob in self.family_members_with_points():
|
||||
|
Reference in New Issue
Block a user