Code video intro

 avatar
unknown
python
4 years ago
2.1 kB
60
Indexable
from manim import *
class Info(Scene):
    def construct(self): 
        # Các màu sắc
        logo_green = "#81b29a"
        logo_blue = "#454866"
        logo_red = "#e07a5f"
        # Thêm âm thanh
        self.add_sound("/Users/quochiep/manimce/hiep/media/videos/pro-1/2160p60/final/intro.mp3",time_offset=0)
        # Tạo các 3 đa giác q1,q2,q3
        q1 = Polygon([0, 0, 0], [6, 0, 0], [3,3,0],[0,2,0],stroke_width=0,color=logo_blue, fill_opacity=1)
        q2 = Polygon([3,3,0],[6,0,0],[6,6,0],[4,6,0],stroke_width=0,color=logo_green, fill_opacity=1)
        q3 = Polygon([3,3,0],[4,6,0],[0,6,0],[0,2,0],stroke_width=0,color=logo_red, fill_opacity=1)
        # Group 3 đa giác, giảm kích thước đa giác, di chuyển về gốc tọa độ
        Group=VGroup(q1,q2,q3).scale(0.5).move_to(ORIGIN)
        # Tạo text 
        text=Text('SÁNG TẠO VIDEO VỚI MANIM',font='Helvitica',weight=LIGHT)
        # Điều chỉnh độ dài text về bằng với 2 lần group
        text.scale_to_fit_width(2*Group.get_width())
        # Đặt vị trí text gần gruop, nằm bên dưới
        text.next_to(Group,DOWN)
        # Cài animation cho group và text nên dùng AnimationGroup
        self.play(
            AnimationGroup(
                Group.animate.shift(1.5*LEFT),
                FadeIn(text,shift=UP,scale=2),
                runtime=1,
                lag_ratio=0.2)
        )
        # Lấy banner trong class có sẵn của Manim CE
        banners = ManimBanner().scale(0.25).move_to(ORIGIN).shift(0.5*LEFT)
        # Cài animation cho banners và đa giác q2
        self.play(
            AnimationGroup(
                Rotate(q2,angle=-PI/2,about_point=[0,-1.5,0]),
                banners.expand(direction="right"),
                runtime=1,
                lag_ratio=0.2)
        )
        # Đưa banners,text vào group đã tạo ban đầu
        Group.add(banners,text)
        # Làm anim fadeout toàn màn hình
        self.play(FadeOut(Group,shift=DOWN,scale=2),run_time=1)
Editor is loading...