반응형
# 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})
self.wait()
self.remove(rect1,rect2)
class MoveToTest(Scene):
def construct(self):
direction = [ORIGIN, LEFT, RIGHT, UP, DOWN]
for d in direction:
self.move_to_point(d)
def move_to_point(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]))
tgt_point = np.array([2,3,0])
self.add(rect1, rect2)
self.wait()
self.play(rect1.move_to, tgt_point, {"aligned_edge": direction})
self.wait()
self.remove(rect1, rect2)
class MoveToTest(Scene):
def construct(self):
direction = [ORIGIN, LEFT, RIGHT, UP, DOWN]
self.move_to_point_mask(ORIGIN, mask=np.array([0.5,0.5,0]))
def move_to_point_mask(self, direction, mask):
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]))
tgt_point = np.array([2,3,0])
self.add(rect1, rect2)
self.wait()
self.play(rect1.move_to, tgt_point, {"aligned_edge": direction, "coor_mask":mask})
self.wait()
self.remove(rect1, rect2)
반응형
'Programming > Manim code' 카테고리의 다른 글
[005]mob.shift (0) | 2020.05.05 |
---|---|
[004]mob.next_to (0) | 2020.05.05 |
[003]mob.to_corner (0) | 2020.05.05 |
[002]mob.to_edge (0) | 2020.05.05 |
about (0) | 2020.05.05 |