본문 바로가기

Programming

(165)
[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,..
[003]mob.to_corner class ToCornerTest(Scene): def construct(self): self.draw_border() self.to_corner_test() # self.to_corner_test(buff=0.5) def draw_border(self): border = Rectangle(width=FRAME_WIDTH, height=FRAME_HEIGHT, stroke_color=YELLOW) self.add(border) def to_corner_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_c..
[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}..
about I'm going to show video clips generated from the source code which is based on Python library, the Manim. Manim is an animation engine for creating math videos. (https://github.com/3b1b/manim) I'll just put some codes and the video clips generated from the code in the page. I thinkg it's enough to catch up how to make an animation with the Python code.