반응형
CyclicReplace
def cyclic(self):
tri = Triangle().to_edge(LEFT, buff=0.5)
square = Square()
circle = Circle().to_edge(RIGHT, buff=0.5)
group = VGroup(tri, square, circle)
self.add(group)
self.wait()
self.play(CyclicReplace(tri, square, circle), run_time=4)
self.wait()
ScaleInPlace
def scale(self):
tri = Triangle().to_edge(LEFT, buff=1)
square = Square()
circle = Circle().to_edge(RIGHT, buff=1)
group = VGroup(tri, square, circle)
self.add(group)
self.wait()
self.play(ScaleInPlace(group, 0.3), run_time=3) # 0.3
self.play(ScaleInPlace(group, 5), run_time=3) # 1.5 = 0.3 * 5
self.play(ScaleInPlace(group, 1/1.5), run_time=3) # 1 = 1.5 * 1/1.5
self.wait()
FadeToColor
def fade_to_color(self):
tri = Triangle(fill_opacity=1).to_edge(LEFT, buff=1)
square = Square(fill_opacity=1)
circle = Circle(fill_opacity=1).to_edge(RIGHT, buff=1)
group = VGroup(tri, square, circle)
self.add(group)
self.wait()
self.play(FadeToColor(group, RED))
self.play(FadeToColor(group, GREEN))
self.play(FadeToColor(group, BLUE))
self.play(FadeToColor(group, YELLOW))
self.play(FadeToColor(group, PINK))
self.wait()
Restore
def restore(self):
circle = Circle(fill_opacity=1, radius=0.3).to_edge(LEFT, buff=2)
circle.save_state()
self.add(circle)
self.wait()
for n, y in zip(np.arange(3,9), np.linspace(3,-3,6)):
obj = RegularPolygon(n, color=RED).move_to(np.array([5,y,0]))
self.play(ReplacementTransform(circle, obj))
self.play(Restore(circle))
self.wait()
MoveToTarget
def move_to_target(self):
arrow = Arrow(LEFT, RIGHT, stroke_width=7, color=RED).to_edge(LEFT, buff=0.5)
circle = Circle(stroke_color=WHITE, fill_opacity=1, color=BLUE).to_edge(RIGHT, buff=1)
self.add(circle, arrow)
target = arrow.generate_target()
target.move_to(circle.get_center(), aligned_edge=RIGHT).set_length(target.get_length()-0.5)
self.play(Rotate(circle,70 * DEGREES, axis=UP))
self.play(MoveToTarget(arrow), rate_func=running_start, run_time=2)
self.wait()
반응형
'Programming > Manim code' 카테고리의 다른 글
[44]AnimationGroup (0) | 2020.05.20 |
---|---|
[43]Transform(3) (0) | 2020.05.20 |
[41]Transform(1) (0) | 2020.05.12 |
[40]Moving/Rotating (0) | 2020.05.12 |
[39]Indicating (0) | 2020.05.12 |