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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统