A community-maintained Python framework for creating mathematical animations.
Feature: argument coor_mask for move_to / next_to: setting coor_mask = X_AXIS or Y_AXIS makes the alignment in just one coordinate
mirefek6b39ba050278
diff --git a/constants.py b/constants.pyindex 2efb773fa..cac15811e 100644--- a/constants.py+++ b/constants.py@@ -53,6 +53,9 @@ RIGHT = np.array(( 1., 0., 0.))LEFT = np.array((-1., 0., 0.))IN = np.array(( 0., 0.,-1.))OUT = np.array(( 0., 0., 1.))+X_AXIS = np.array(( 1., 0., 0.))+Y_AXIS = np.array(( 0., 1., 0.))+Z_AXIS = np.array(( 0., 0., 1.))TOP = SPACE_HEIGHT*UPBOTTOM = SPACE_HEIGHT*DOWNdiff --git a/mobject/mobject.py b/mobject/mobject.pyindex cf01b713c..6618d1aa2 100644--- a/mobject/mobject.py+++ b/mobject/mobject.py@@ -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 = selfpoint_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 selfdef 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_mobjectpoint_to_align = self.get_critical_point(aligned_edge)- self.shift(target - point_to_align)+ self.shift((target - point_to_align)*coor_mask)return selfdef replace(self, mobject, dim_to_match = 0, stretch = False):