You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add three animations that together simulate a typing animation (#3612)
* feat: Add animations that together simulate typing
AddTextLetterByLetterWithCursor
RemoveTextLetterByLetterWithCursor
Blink
* Revert "feat: Add animations that together simulate typing"
This reverts commit 5fe2568.
* Revert "Revert "feat: Add animations that together simulate typing""
This reverts commit 6a8244a.
* Add new animations to __all__
* Temporarily remove docs example
* Modify "Blink" and add docstring examples back in
To avoid 0-second animations, which fail docstring test
* Address requested changes
Fix imports
Remove redundant constructor arguments
Improve names
* Shorten names
from ..mobject.types.vectorized_mobjectimportVMobject
94
97
from ..utils.bezierimportinteger_interpolate
@@ -674,3 +677,176 @@ def __init__(
674
677
)
675
678
)
676
679
super().__init__(*anims, **kwargs)
680
+
681
+
682
+
classTypeWithCursor(AddTextLetterByLetter):
683
+
"""Similar to :class:`~.AddTextLetterByLetter` , but with an additional cursor mobject at the end.
684
+
685
+
Parameters
686
+
----------
687
+
time_per_char
688
+
Frequency of appearance of the letters.
689
+
cursor
690
+
:class:`~.Mobject` shown after the last added letter.
691
+
buff
692
+
Controls how far away the cursor is to the right of the last added letter.
693
+
keep_cursor_y
694
+
If ``True``, the cursor's y-coordinate is set to the center of the ``Text`` and remains the same throughout the animation. Otherwise, it is set to the center of the last added letter.
695
+
leave_cursor_on
696
+
Whether to show the cursor after the animation.
697
+
698
+
.. tip::
699
+
This is currently only possible for class:`~.Text` and not for class:`~.MathTex`.
700
+
701
+
702
+
Examples
703
+
--------
704
+
705
+
.. manim:: InsertingTextExample
706
+
:ref_classes: Blink
707
+
708
+
class InsertingTextExample(Scene):
709
+
def construct(self):
710
+
text = Text("Inserting", color=PURPLE).scale(1.5).to_edge(LEFT)
"""Similar to :class:`~.RemoveTextLetterByLetter` , but with an additional cursor mobject at the end.
794
+
795
+
Parameters
796
+
----------
797
+
time_per_char
798
+
Frequency of appearance of the letters.
799
+
cursor
800
+
:class:`~.Mobject` shown after the last added letter.
801
+
buff
802
+
Controls how far away the cursor is to the right of the last added letter.
803
+
keep_cursor_y
804
+
If ``True``, the cursor's y-coordinate is set to the center of the ``Text`` and remains the same throughout the animation. Otherwise, it is set to the center of the last added letter.
805
+
leave_cursor_on
806
+
Whether to show the cursor after the animation.
807
+
808
+
.. tip::
809
+
This is currently only possible for class:`~.Text` and not for class:`~.MathTex`.
810
+
811
+
812
+
Examples
813
+
--------
814
+
815
+
.. manim:: DeletingTextExample
816
+
:ref_classes: Blink
817
+
818
+
class DeletingTextExample(Scene):
819
+
def construct(self):
820
+
text = Text("Deleting", color=PURPLE).scale(1.5).to_edge(LEFT)
0 commit comments