TypeWithCursor¶
Qualified name: manim.animation.creation.TypeWithCursor
- class TypeWithCursor(mobject=None, *args, use_override=True, **kwargs)[source]¶
Bases:
AddTextLetterByLetter
Similar to
AddTextLetterByLetter
, but with an additional cursor mobject at the end.- Parameters:
time_per_char (float) – Frequency of appearance of the letters.
cursor (Mobject) –
Mobject
shown after the last added letter.buff (float) – Controls how far away the cursor is to the right of the last added letter.
keep_cursor_y (bool) – If
True
, the cursor’s y-coordinate is set to the center of theText
and remains the same throughout the animation. Otherwise, it is set to the center of the last added letter.leave_cursor_on (bool) – Whether to show the cursor after the animation.
tip:: (..) – This is currently only possible for class:~.Text and not for class:~.MathTex.
text (Text)
Examples
Example: 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))
References:
Blink
Methods
Begin the animation.
Clean up the
Scene
after finishing the animation.Finish the animation.
update_submobject_list
Attributes
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)¶
Initialize self. See help(type(self)) for accurate signature.
- begin()[source]¶
Begin the animation.
This method is called right as an animation is being played. As much initialization as possible, especially any mobject copying, should live in this method.
- Return type:
None