반응형
lag_ration test
class AnimationGroupTest(Scene):
def construct(self):
self.animation_group()
def animation_group(self):
self.t1 = TextMobject("Hello").shift(UP*2).to_edge(LEFT, buff=1)
self.t2 = TextMobject("Wordld").shift(UP*2).to_edge(RIGHT, buff=1)
self.shape1 = Circle().to_edge(LEFT, buff=1)
self.shape2 = Square().to_edge(RIGHT, buff=1)
self.arrow1 = Arrow().shift(DOWN*2).to_edge(LEFT, buff=1)
self.arrow2 = Arrow().shift(DOWN*2).to_edge(RIGHT, buff=1)
self.do_animation("1. lag_ratio=0", 0)
self.do_animation("2. lag_ratio=0.5", 0.5)
self.do_animation("3. lag_ratio=1", 1)
def do_animation(self, name, ratio):
text = Text(name, stroke_width=0, color=YELLOW, size=0.4).to_corner(UL, buff=0.5)
self.add(text, self.t1, self.shape1, self.arrow1)
self.wait(2)
self.play(
AnimationGroup(
TransformFromCopy(self.t1, self.t2, run_time=2),
TransformFromCopy(self.shape1, self.shape2, run_time=2),
TransformFromCopy(self.arrow1, self.arrow2, run_time=2),
lag_ratio=ratio,
)
)
self.wait(0.5)
self.remove(text, self.t1, self.shape1, self.arrow1)
Succession Class
def succession(self):
text = Text("Succession", stroke_width=0, color=YELLOW, size=0.4).to_corner(UL, buff=0.5)
t1 = TextMobject("Hello").shift(UP * 2).to_edge(LEFT, buff=1)
t2 = TextMobject("Wordld").shift(UP * 2).to_edge(RIGHT, buff=1)
shape1 = Circle().to_edge(LEFT, buff=1)
shape2 = Square().to_edge(RIGHT, buff=1)
arrow1 = Arrow().shift(DOWN * 2).to_edge(LEFT, buff=1)
arrow2 = Arrow().shift(DOWN * 2).to_edge(RIGHT, buff=1)
self.add(text, t1, shape1, arrow1)
self.wait(2)
self.play(
Succession(
Transform(t1,t2),
Transform(shape1, shape2),
Transform(arrow1, arrow2),
)
)
LaggedStart Class
def lagged_start(self):
text = Text("LaggedStart", stroke_width=0, color=YELLOW, size=0.4).to_corner(UL, buff=0.5)
t1 = TextMobject("Hello").shift(UP * 2).to_edge(LEFT, buff=1)
t2 = TextMobject("Wordld").shift(UP * 2).to_edge(RIGHT, buff=1)
shape1 = Circle().to_edge(LEFT, buff=1)
shape2 = Square().to_edge(RIGHT, buff=1)
arrow1 = Arrow().shift(DOWN * 2).to_edge(LEFT, buff=1)
arrow2 = Arrow().shift(DOWN * 2).to_edge(RIGHT, buff=1)
self.add(text, t1, shape1, arrow1)
self.wait(2)
self.play(
LaggedStart(
Transform(t1, t2),
Transform(shape1, shape2),
Transform(arrow1, arrow2),
lag_ratio=0.3,
)
)
LaggedStartMap Class
def lagged_start_map(self):
text = VGroup(
TextMobject("Monday"),
TextMobject("Tuesday"),
TextMobject("Wednesday"),
TextMobject("Thursday"),
TextMobject("Friday"),
).arrange(DOWN)
self.play(
LaggedStartMap(FadeInFrom, text, lambda m: (m, LEFT), lag_ratio=0.2),
run_time=10,
)
self.wait()
반응형
'Programming > Manim code' 카테고리의 다른 글
[46]Mobject moving/coloring Animation (0) | 2020.05.29 |
---|---|
[45]Special Effects (0) | 2020.05.29 |
[43]Transform(3) (0) | 2020.05.20 |
[42]Transform (2) (0) | 2020.05.12 |
[41]Transform(1) (0) | 2020.05.12 |