mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
submobject_family -> get_family
This commit is contained in:
parent
eeff860588
commit
51e6b66c95
14 changed files with 27 additions and 27 deletions
|
@ -1302,7 +1302,7 @@ class SolvingASystemWithOrthonormalMatrix(LinearTransformationScene):
|
|||
equation.movers = VGroup(
|
||||
moving_var, moving_output_vect_label, moving_column_mob
|
||||
)
|
||||
for element in moving_column_mob.target.submobject_family():
|
||||
for element in moving_column_mob.target.get_family():
|
||||
if not isinstance(element, TexMobject):
|
||||
continue
|
||||
tex_string = element.get_tex_string()
|
||||
|
|
|
@ -47,7 +47,7 @@ class MultiCamera(MovingCamera):
|
|||
to_add = list(mobjects)
|
||||
if not self.allow_cameras_to_capture_their_own_display:
|
||||
to_add = list_difference_update(
|
||||
to_add, imfc.submobject_family()
|
||||
to_add, imfc.get_family()
|
||||
)
|
||||
imfc.camera.capture_mobjects(to_add, **kwargs)
|
||||
MovingCamera.capture_mobjects(self, mobjects, **kwargs)
|
||||
|
|
|
@ -171,13 +171,13 @@ class PiCreatureScene(Scene):
|
|||
for pi_creature in self.get_pi_creatures():
|
||||
if pi_creature not in self.get_mobjects():
|
||||
continue
|
||||
if pi_creature in first_anim.mobject.submobject_family():
|
||||
if pi_creature in first_anim.mobject.get_family():
|
||||
continue
|
||||
anims_with_pi_creature = [anim for anim in animations if pi_creature in anim.mobject.submobject_family()]
|
||||
anims_with_pi_creature = [anim for anim in animations if pi_creature in anim.mobject.get_family()]
|
||||
for anim in anims_with_pi_creature:
|
||||
if isinstance(anim, Transform):
|
||||
index = anim.mobject.submobject_family().index(pi_creature)
|
||||
target_family = anim.target_mobject.submobject_family()
|
||||
index = anim.mobject.get_family().index(pi_creature)
|
||||
target_family = anim.target_mobject.get_family()
|
||||
target = target_family[index]
|
||||
if isinstance(target, PiCreature):
|
||||
target.look_at(point_of_interest)
|
||||
|
|
|
@ -126,7 +126,7 @@ class Mobject(Container):
|
|||
copy_mobject.submobjects = [
|
||||
submob.copy() for submob in self.submobjects
|
||||
]
|
||||
family = self.submobject_family()
|
||||
family = self.get_family()
|
||||
for attr, value in list(self.__dict__.items()):
|
||||
if isinstance(value, Mobject) and value in family and value is not self:
|
||||
setattr(copy_mobject, attr, value.copy())
|
||||
|
@ -628,7 +628,7 @@ class Mobject(Container):
|
|||
return self
|
||||
|
||||
def fade_to(self, color, alpha):
|
||||
for mob in self.submobject_family():
|
||||
for mob in self.get_family():
|
||||
mob.fade_to_no_recurse(self, color, alpha)
|
||||
return self
|
||||
|
||||
|
@ -637,7 +637,7 @@ class Mobject(Container):
|
|||
return self
|
||||
|
||||
def fade(self, darkness=0.5):
|
||||
for submob in self.submobject_family():
|
||||
for submob in self.get_family():
|
||||
submob.fade_no_recurse(darkness)
|
||||
return self
|
||||
|
||||
|
@ -660,7 +660,7 @@ class Mobject(Container):
|
|||
if not hasattr(self, "saved_state") or self.save_state is None:
|
||||
raise Exception("Trying to restore without having saved")
|
||||
self.align_data(self.saved_state)
|
||||
for sm1, sm2 in zip(self.submobject_family(), self.saved_state.submobject_family()):
|
||||
for sm1, sm2 in zip(self.get_family(), self.saved_state.get_family()):
|
||||
sm1.interpolate(sm1, sm2, 1)
|
||||
return self
|
||||
|
||||
|
@ -806,14 +806,14 @@ class Mobject(Container):
|
|||
result = [self] if len(self.points) > 0 else []
|
||||
return result + self.submobjects
|
||||
|
||||
def submobject_family(self):
|
||||
def get_family(self):
|
||||
sub_families = list(map(Mobject.submobject_family, self.submobjects))
|
||||
all_mobjects = [self] + list(it.chain(*sub_families))
|
||||
#all_mobjects = list(it.chain(*sub_families)) + [self]
|
||||
return remove_list_redundancies(all_mobjects)
|
||||
|
||||
def family_members_with_points(self):
|
||||
return [m for m in self.submobject_family() if m.get_num_points() > 0]
|
||||
return [m for m in self.get_family() if m.get_num_points() > 0]
|
||||
|
||||
def arrange_submobjects(self, direction=RIGHT, center=True, **kwargs):
|
||||
for m1, m2 in zip(self.submobjects, self.submobjects[1:]):
|
||||
|
@ -853,11 +853,11 @@ class Mobject(Container):
|
|||
submob.shuffle_submobjects(recursive=True)
|
||||
random.shuffle(self.submobjects)
|
||||
|
||||
def print_submobject_family(self, n_tabs=0):
|
||||
def print_get_family(self, n_tabs=0):
|
||||
"""For debugging purposes"""
|
||||
print("\t" * n_tabs, self, id(self))
|
||||
for submob in self.submobjects:
|
||||
submob.print_submobject_family(n_tabs + 1)
|
||||
submob.print_get_family(n_tabs + 1)
|
||||
|
||||
# Alignment
|
||||
def align_data(self, mobject):
|
||||
|
|
|
@ -252,7 +252,7 @@ class VMobject(Mobject):
|
|||
def set_sheen_direction(self, direction, family=True):
|
||||
direction = np.array(direction)
|
||||
if family:
|
||||
for submob in self.submobject_family():
|
||||
for submob in self.get_family():
|
||||
submob.sheen_direction = direction
|
||||
else:
|
||||
self.sheen_direction = direction
|
||||
|
|
|
@ -790,7 +790,7 @@ class InputOutputScene(Scene):
|
|||
label.to_edge(UP, buff = MED_SMALL_BUFF)
|
||||
plane.add(label)
|
||||
plane.label = label
|
||||
for submob in plane.submobject_family():
|
||||
for submob in plane.get_family():
|
||||
if isinstance(submob, TexMobject) and hasattr(submob, "background_rectangle"):
|
||||
submob.remove(submob.background_rectangle)
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ class TwoDScreenInOurThreeDWorld(AltTeacherStudentsScene, ThreeDScene):
|
|||
|
||||
everything = VGroup(laptop, *self.mobjects)
|
||||
everything.generate_target()
|
||||
# for mob in everything.target.submobject_family():
|
||||
# for mob in everything.target.get_family():
|
||||
# if isinstance(mob, PiCreature):
|
||||
# mob.change_mode("confused")
|
||||
everything.target.rotate(TAU/12, LEFT)
|
||||
|
|
|
@ -768,7 +768,7 @@ class GroupOfCubeSymmetries(ThreeDScene):
|
|||
randy = Randolph(mode = "pondering")
|
||||
# randy.pupils.shift(0.01*OUT)
|
||||
# randy.add(randy.pupils.copy().shift(0.02*IN))
|
||||
# for submob in randy.submobject_family():
|
||||
# for submob in randy.get_family():
|
||||
# submob.part_of_three_d_mobject = True
|
||||
randy.scale(0.5)
|
||||
face = cube[1]
|
||||
|
|
|
@ -537,7 +537,7 @@ class CoordinateSystemWalkthrough(VectorScene):
|
|||
y_tick_marks = x_tick_marks.copy().rotate(np.pi/2)
|
||||
tick_marks = VMobject(x_tick_marks, y_tick_marks)
|
||||
tick_marks.set_color(WHITE)
|
||||
plane_lines = [m for m in plane.submobject_family() if isinstance(m, Line)]
|
||||
plane_lines = [m for m in plane.get_family() if isinstance(m, Line)]
|
||||
origin_words = TextMobject("Origin")
|
||||
origin_words.shift(2*UP+2*LEFT)
|
||||
dot = Dot(radius = 0.1).set_color(RED)
|
||||
|
|
|
@ -339,7 +339,7 @@ class IntroduceIdeaOfComposition(RotationThenShear):
|
|||
def show_overall_effect(self, matrix):
|
||||
everything = self.get_mobjects()
|
||||
everything = list_difference_update(
|
||||
everything, matrix.submobject_family()
|
||||
everything, matrix.get_family()
|
||||
)
|
||||
self.play(*list(map(FadeOut, everything)) + [Animation(matrix)])
|
||||
new_matrix = matrix.copy()
|
||||
|
|
|
@ -843,7 +843,7 @@ class TranslateFromJenny(JenniferScene):
|
|||
)
|
||||
self.wait()
|
||||
everything = self.get_mobjects()
|
||||
for submob in self.jenny_plane.submobject_family():
|
||||
for submob in self.jenny_plane.get_family():
|
||||
everything.remove(submob)
|
||||
self.play(
|
||||
Transform(self.jenny_plane, self.plane),
|
||||
|
|
|
@ -2847,7 +2847,7 @@ class SierpinskiGraphScene(Scene):
|
|||
circles.set_stroke(width = self.graph_stroke_width)
|
||||
|
||||
self.nodes = VGroup()
|
||||
for circle in circles.submobject_family():
|
||||
for circle in circles.get_family():
|
||||
if not isinstance(circle, Circle):
|
||||
continue
|
||||
node = VGroup()
|
||||
|
|
|
@ -1394,7 +1394,7 @@ class Lemma1(DistanceProductScene):
|
|||
self.distance_lines,
|
||||
self.numeric_distance_labels,
|
||||
self.distance_product_column,
|
||||
).submobject_family())
|
||||
).get_family())
|
||||
self.play(
|
||||
ApplyMethod(
|
||||
observer_angle_tracker.set_value, observer_angle + 0.05 * TAU,
|
||||
|
|
|
@ -166,7 +166,7 @@ class PentagonalPiCreatureFractal(PentagonalFractal):
|
|||
SelfSimilarFractal.init_colors(self)
|
||||
internal_pis = [
|
||||
pi
|
||||
for pi in self.submobject_family()
|
||||
for pi in self.get_family()
|
||||
if isinstance(pi, PiCreature)
|
||||
]
|
||||
colors = color_gradient(self.colors, len(internal_pis))
|
||||
|
@ -202,7 +202,7 @@ class PiCreatureFractal(VMobject):
|
|||
VMobject.init_colors(self)
|
||||
internal_pis = [
|
||||
pi
|
||||
for pi in self.submobject_family()
|
||||
for pi in self.get_family()
|
||||
if isinstance(pi, PiCreature)
|
||||
]
|
||||
random.seed(self.random_seed)
|
||||
|
|
|
@ -206,7 +206,7 @@ class Scene(Container):
|
|||
# Return only those which are not in the family
|
||||
# of another mobject from the scene
|
||||
mobjects = self.get_mobjects()
|
||||
families = [m.submobject_family() for m in mobjects]
|
||||
families = [m.get_family() for m in mobjects]
|
||||
|
||||
def is_top_level(mobject):
|
||||
num_families = sum([
|
||||
|
@ -296,7 +296,7 @@ class Scene(Container):
|
|||
for mob in list_to_examine:
|
||||
if mob in set_to_remove:
|
||||
continue
|
||||
intersect = set_to_remove.intersection(mob.submobject_family())
|
||||
intersect = set_to_remove.intersection(mob.get_family())
|
||||
if intersect:
|
||||
add_safe_mobjects_from_list(mob.submobjects, intersect)
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue