반응형
class MovingRotating(Scene):
def construct(self):
ani_classes = {
"MoveAlongPath": (MoveAlongPath,),
"Rotate": (Rotate,),
"Rotating": (Rotating,),
"TurnInsideOut": (TurnInsideOut,),
}
idx = 1
for name, ani in ani_classes.items():
if name == "MoveAlongPath" :
self.move_along_path(idx, name)
elif name == "Rotate":
self.rotate(idx, name)
elif name == "Rotating":
self.rotate(idx, name)
elif name == "TurnInsideOut":
self.turn_inside_out(idx, name)
self.wait()
idx += 1
def move_along_path(self,idx,ani_name):
name_text = Text(str(idx) + ". " + ani_name, stroke_width=0, size=0.4, color=YELLOW)
name_text.to_corner(UL)
arc = ArcBetweenPoints(LEFT*4+UP*2, RIGHT*4 + DOWN*2, angle=PI/2, stroke_width=8)
circle = Circle(color=YELLOW, fill_color=YELLOW, fill_opacity=0.6)
circle.move_to(arc.get_start())
self.add(name_text)
self.add(arc, circle)
self.wait()
self.play(MoveAlongPath(circle,arc), run_time=3)
self.remove(name_text, arc, circle)
def rotate(self, idx, ani_name):
name_text = Text(str(idx) + ". " + ani_name, stroke_width=0, size=0.4, color=YELLOW)
name_text.to_corner(UL)
square = Square()
self.add(name_text,square)
self.wait()
self.play(Rotate(square, angle=PI/4), run_time=3)
self.play(Rotate(square, angle=380 * DEGREES, axis=RIGHT), run_time=3)
self.wait()
self.remove(name_text,square)
def rotating(self, idx, ani_name):
name_text = Text(str(idx) + ". " + ani_name, stroke_width=0, size=0.4, color=YELLOW)
name_text.to_corner(UL)
square = Square()
self.add(name_text,square)
self.wait()
self.play(Rotating(square, radians=PI/4), run_time=3)
self.play(Rotating(square, radians=380 * DEGREES, axis=RIGHT), run_time=3)
self.wait()
self.remove(name_text, square)
def turn_inside_out(self, idx, ani_name):
name_text = Text(str(idx) + ". " + ani_name, stroke_width=0, size=0.4, color=YELLOW)
name_text.to_corner(UL)
square = Square()
self.add(name_text, square)
self.wait()
self.play(TurnInsideOut(square ), run_time=3)
self.wait()
반응형
'Programming > Manim code' 카테고리의 다른 글
[42]Transform (2) (0) | 2020.05.12 |
---|---|
[41]Transform(1) (0) | 2020.05.12 |
[39]Indicating (0) | 2020.05.12 |
[38]Animation: Creation (0) | 2020.05.12 |
[37]Animation's rate_func (0) | 2020.05.12 |