[008]align_to/arrange/arrange_in_grid
align_to class AlignToTest(Scene): def construct(self): dir_str = [ 'UP', 'DOWN', 'LEFT', 'RIGHT'] dir_list = [ UP, DOWN, LEFT, RIGHT] rect = Rectangle(width=1, height=0.4) rect_tgt = Rectangle(width=3, height=2).shift(RIGHT * 3, UP * 2) self.add(rect, rect_tgt) for str, dir in zip(dir_str, dir_list): new_rect = rect.copy() obj = self.get_text_rect(str, new_rect) self.play(obj.align_to, rect_tgt..
[004]mob.next_to
1. next_to(obj, ORIGIN/LEFT/RIGHT/UP/DOWN/UL/UR/DL/DR) class NextToTest(Scene): def construct(self): dir_str = ['ORIGIN', 'LEFT', 'RIGHT', 'UP', 'DOWN', 'UL', 'UR', 'DL', 'DR'] dir_list = [ORIGIN, LEFT, RIGHT, UP, DOWN, UL, UR, DL, DR] #1. next_to(obj, ORIGIN/LEFT/RIGHT/UP/DOWN/UL/UR/DL/DR) for str, d in zip(dir_str, dir_list): self.next_to_obj(str,d) def next_to_obj(self, str, direction=ORIGIN,..
[002]mob.to_edge
# based on the 'Scene' class def construct(self): self.to_edge_test() # self.to_edge_test(buff=0.5) def to_edge_test(self, buff=0): text = Text("Hello", font='Arial', stroke_width=1, size=0.4) rect = Rectangle(width=0.3, height=text.get_height(),stroke_color=RED) group = VGroup(rect,text).arrange(RIGHT) group.save_state() self.add(group) for d in [LEFT,RIGHT,UP,DOWN]: self.play(group.to_edge, d,..
[001]mob.move_to
# based on the 'Scene' def construct(self): direction = [ORIGIN, LEFT, RIGHT, UP, DOWN] for d in direction: self.move_to_obj(d) def move_to_obj(self, direction): rect1 = Rectangle(width=0.4, height=0.2, stroke_color=RED) rect2 = Rectangle(width=1, height=1, stroke_color=BLUE).move_to(np.array([2, 3, 0])) self.add(rect1,rect2) self.wait() self.play(rect1.move_to, rect2, {"aligned_edge":direction}..