TypeWithCursor¶
完全限定名: manim.animation.creation.TypeWithCursor
- class TypeWithCursor(mobject=None, *args, use_override=True, **kwargs)[源码]¶
-
与
AddTextLetterByLetter
类似,但在末尾添加了一个额外的光标 Mobject。- 参数:
**time_per_char** (float) – 字母出现频率。
buff (float) – 控制光标与最后一个添加的字母右侧的距离。
keep_cursor_y (bool) – 如果为
True
,光标的 y 坐标将设置为Text
的中心并在整个动画过程中保持不变。否则,它将设置为最后一个添加字母的中心。leave_cursor_on (bool) – 动画结束后是否显示光标。
提示:: (..) – 目前这仅适用于类:~.Text,不适用于类:~.MathTex。
**text** (Text)
示例
示例: InsertingTextExample ¶
from manim import * class InsertingTextExample(Scene): def construct(self): text = Text("Inserting", color=PURPLE).scale(1.5).to_edge(LEFT) cursor = Rectangle( color = GREY_A, fill_color = GREY_A, fill_opacity = 1.0, height = 1.1, width = 0.5, ).move_to(text[0]) # Position the cursor self.play(TypeWithCursor(text, cursor)) self.play(Blink(cursor, blinks=2))
class InsertingTextExample(Scene): def construct(self): text = Text("Inserting", color=PURPLE).scale(1.5).to_edge(LEFT) cursor = Rectangle( color = GREY_A, fill_color = GREY_A, fill_opacity = 1.0, height = 1.1, width = 0.5, ).move_to(text[0]) # Position the cursor self.play(TypeWithCursor(text, cursor)) self.play(Blink(cursor, blinks=2))
参考:
Blink
方法
属性
run_time
- _original__init__(text, cursor, buff=0.1, keep_cursor_y=True, leave_cursor_on=True, time_per_char=0.1, reverse_rate_function=False, introducer=True, **kwargs)¶
初始化自身。有关准确签名,请参阅 help(type(self))。