mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 05:24:22 +08:00
Feature: argument coor_mask for move_to / next_to:
setting coor_mask = X_AXIS or Y_AXIS makes the alignment in just one coordinate
This commit is contained in:
@ -296,6 +296,7 @@ class Mobject(Container):
|
||||
aligned_edge = ORIGIN,
|
||||
submobject_to_align = None,
|
||||
index_of_submobject_to_align = None,
|
||||
coor_mask = np.array([1,1,1]),
|
||||
):
|
||||
if isinstance(mobject_or_point, Mobject):
|
||||
mob = mobject_or_point
|
||||
@ -315,7 +316,7 @@ class Mobject(Container):
|
||||
else:
|
||||
aligner = self
|
||||
point_to_align = aligner.get_critical_point(aligned_edge - direction)
|
||||
self.shift(target_point - point_to_align + buff*direction)
|
||||
self.shift((target_point - point_to_align + buff*direction)*coor_mask)
|
||||
return self
|
||||
|
||||
def align_to(self, mobject_or_point, direction = ORIGIN, alignment_vect = UP):
|
||||
@ -403,13 +404,14 @@ class Mobject(Container):
|
||||
submob.scale(1./factor)
|
||||
return self
|
||||
|
||||
def move_to(self, point_or_mobject, aligned_edge = ORIGIN):
|
||||
def move_to(self, point_or_mobject, aligned_edge = ORIGIN,
|
||||
coor_mask = np.array([1,1,1])):
|
||||
if isinstance(point_or_mobject, Mobject):
|
||||
target = point_or_mobject.get_critical_point(aligned_edge)
|
||||
else:
|
||||
target = point_or_mobject
|
||||
point_to_align = self.get_critical_point(aligned_edge)
|
||||
self.shift(target - point_to_align)
|
||||
self.shift((target - point_to_align)*coor_mask)
|
||||
return self
|
||||
|
||||
def replace(self, mobject, dim_to_match = 0, stretch = False):
|
||||
|
Reference in New Issue
Block a user