반응형
Example 1
class CoordinateEx1(Scene):
def construct(self):
#1. create objects
title = self.get_title()
body = self.get_body()
subtitle = self.get_subtitle()
#2. locate objects
title.move_to(ORIGIN).to_edge(UP, buff=1)
body.next_to(title, DOWN, buff=1)
subtitle.to_edge(DOWN, buff=0.5)
#3. animate objects
self.play(FadeIn(title), run_time=2)
self.play(FadeIn(body), run_time=2)
self.play(FadeIn(subtitle), run_time=2)
self.wait(2)
def get_text(self, str, color=WHITE, size=0.4):
return Text(str, font='굴림', stroke_width=1, color=color, size=size)
def get_title(self):
t1 = self.get_text("IMF 국제통화기금", color=BLUE, size=0.4 )
t2 = self.get_text("2020 세계 경제 전망", color=WHITE, size=0.6)
t2.next_to(t1, RIGHT, buff=0.3)
text = VGroup(t1, t2)
underline = Line(LEFT, RIGHT, color = GREY).set_width(text.get_width())
underline.next_to(text, DOWN, buff=0.1)
return VGroup(text, underline)
def get_body(self):
t1 = self.get_text("세계", color=WHITE, size=1)
t2 = self.get_text("-3%", color=RED, size=1.4)
t2.next_to(t1, RIGHT, buff=0.8)
return VGroup(t1, t2)
def get_subtitle(self):
rect1 = Rectangle(width=FRAME_WIDTH-1.5, height=0.4, fill_opacity=1, fill_color=BLUE, stroke_width=0)
t1 = self.get_text("쿠오모", color=WHITE, size=0.3)
t2 = self.get_text("뉴욕주지사", color=WHITE, size=0.2)
t2.next_to(t1, RIGHT, buff=0.2)
up_text = VGroup(t1,t2).move_to(rect1, LEFT).shift(RIGHT*0.1)
rect1.add(up_text)
rect2 = Rectangle(width=FRAME_WIDTH-1.5, height=0.8, fill_opacity=1, fill_color=WHITE, stroke_width=0)
t3 = self.get_text("세계 경제 전망이 ...,", color=BLUE_E, size=0.3)
t4 = self.get_text("물품 구매도 각 주가 책임져야...", color=BLUE_E, size=0.3)
t4.next_to(t3, DOWN, aligned_edge=LEFT, buff=0.1)
down_text = VGroup(t3,t4).move_to(rect2, LEFT).shift(RIGHT*0.1)
rect2.add(down_text)
rect2.next_to(rect1, DOWN, buff=0)
return VGroup(rect1, rect2)
Example 2
class CoordinateEx2(Scene):
def construct(self):
dot = Dot()
dot.to_edge(LEFT)
self.add(dot)
self.wait()
for i in range(0,5):
self.move_dot(dot)
def move_dot(self, dot):
d1 = dot.copy()
d2 = dot.copy()
d3 = dot.copy()
self.play(
d1.to_corner, UR,
d2.to_edge, RIGHT,
d3.to_corner, DR,
)
self.remove(d1, d2, d3)
반응형
'Programming > Manim code' 카테고리의 다른 글
[008]align_to/arrange/arrange_in_grid (0) | 2020.05.05 |
---|---|
[007]mob.get_left/mob.get_right (0) | 2020.05.05 |
[005]mob.shift (0) | 2020.05.05 |
[004]mob.next_to (0) | 2020.05.05 |
[003]mob.to_corner (0) | 2020.05.05 |