from manim import * import numpy as np from numpy import array, pi, cos, sin run_time = 1 data = [[1, 2], [3, 4]] defdot(pos, **kwargs): return Dot(pos, **kwargs) classR022_00(Scene): defconstruct(self): sc = self self.play(*[FadeIn(_o) for _o in [MarkupText('<b>Hello Manim</b>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('<i>Hello Manim</i>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('Manim教程<sup>说明</sup>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('Manim教程<sub>附件</sub>')]], run_time=1.0) self.wait(0.5) self.wait(1.10)
2.2. 字体
设置字体可以使用font属性,不过这里我们通过HTML语法来设置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
from manim import * import numpy as np from numpy import array, pi, cos, sin run_time = 1 data = [[1, 2], [3, 4]] defdot(pos, **kwargs): return Dot(pos, **kwargs) classR022_01(Scene): defconstruct(self): sc = self self.play(*[FadeIn(_o) for _o in [MarkupText('<tt>Hello Manim</tt>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('<span font_family="Hack"> Hello Manim</span>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('<span font_family="STLiti"> Hello Manim</span>')]], run_time=1.0) self.wait(0.5) self.wait(2.10)
2.3. 颜色
通过HTML语法,除了可以设置颜色和渐变色,还可以设置背景色。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
from manim import * import numpy as np from numpy import array, pi, cos, sin run_time = 1 data = [[1, 2], [3, 4]] defdot(pos, **kwargs): return Dot(pos, **kwargs) classR022_02(Scene): defconstruct(self): sc = self self.play(*[FadeIn(_o) for _o in [MarkupText('<span fgcolor="red">Hello Manim</span>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('<span bgcolor="blue">Hello Manim</span>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('<gradient from="green" to="yellow"> Hello Manim</gradient>')]], run_time=1.0) self.wait(0.5) self.wait(2.10)
2.4. 划线
划线是无法通过属性设置来完成的,所以之前介绍的Text和Paragraph没有这个功能。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
from manim import * import numpy as np from numpy import array, pi, cos, sin run_time = 1 data = [[1, 2], [3, 4]] defdot(pos, **kwargs): return Dot(pos, **kwargs) classR022_03(Scene): defconstruct(self): sc = self self.play(*[FadeIn(_o) for _o in [MarkupText('<span overline="single" overline_color="green"> Hello Manim</span>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('<span underline="single" underline_color="blue"> Hello Manim</span>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('<span underline="double" underline_color="blue"> Hello Manim</span>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('<span strikethrough="true" strikethrough_color="red"> Hello Manim</span>')]], run_time=1.0) self.play(*[FadeIn(_o) for _o in [MarkupText('<span underline="error" underline_color="yellow"> Hello Manim</span>')]], run_time=1.0) self.wait(0.5) self.wait(0.40)
3. 附件
数学动画引擎
记录生活、理财与折腾
主观感受,仅供参考。本文采用 本文采用 CC BY-NC-SA 4.0 许可 协议,
完整转载请注明来自 数学动画引擎。