随笔- 310  文章- 1  评论- 0  阅读- 86066 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#coding:utf-8
#pip install manim
#ffmpeg官网 http://ffmpeg.org/
from manim import *
class Draw(Scene):
    def construct(self):
        text1 = Text(
            'Hello World',
            t2c={'[:1]': '#3174f0', '[1:2]': '#e53125',
                 '[2:3]': '#fbb003', '[3:4]': '#3174f4',
                 '[4:5]': '#269a43', '[5:6]': '#e53125',
                 '[6:7]': '#3174f3', '[7:8]': '#e53125',
                 '[8:9]': '#fbb003', '[9:]': '#317460'}, font_size=60)
        self.play(Create(text1))
        self.play(text1.animate.scale(2))
        self.wait()
 
# manim -pql manim_text.py Draw

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#coding:utf-8
#pip install manim
#ffmpeg官网 http://ffmpeg.org/
from manim import *
 
# 设置文本大小
class Demo2(Scene):
    def construct(self):
        # WaterMark.construct(self)
        s = "Python数据之道"
        t1 = Text(s)
        t1.to_edge(UP,buff=0.5)
        t2 = Text(s).scale(2)
        t2.next_to(t1,DOWN)
        t3 = Text(s).set_width(10)
        t3.next_to(t2,DOWN)
        t4 = Text(s,font_size=40)
        t4.next_to(t3,DOWN)      
        self.add(t1)
        self.play(Write(t2))
        self.play(Create(t3))
        self.play(Write(t4))
        self.wait()
 
 
class Code1(Scene):
    def construct(self):
        # WaterMark.construct(self)
        code_str_1 = """
        def quickSort(Array): 
            n = len(Array)
            if n <= 1:
                return Array
            baseline = Array[0]
            left = [Array[i] for i in range(1, len(Array)) if Array[i] < baseline]
            right = [Array[i] for i in range(1, len(Array)) if Array[i] >= baseline]
            return quickSort(left) + [baseline] + quickSort(right)
        """
        code1 = Code(
            code=code_str_1,
            tab_width=4,
            background="window",
            language="Python",
            font="Monospace",
            insert_line_no=False# 是否显示代码行数
            style='monokai',
        )
  
        code1.scale(0.8).to_edge(UP,buff=1)
  
        self.play(Write(code1))
        self.wait()

  manim -pql manim_text.py Demo2

       manim -pql manim_text.py Code1

 

 

  

 posted on   boye169  阅读(36)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示