Skip to content

Commit a6b090f

Browse files
authored
Merge pull request #84 from huguesdevimeux/added-letter-by-letter
added AddTextLetterByLetter
2 parents eae8e9b + 0d119c3 commit a6b090f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

manim/animation/creation.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ def interpolate_mobject(self, alpha):
140140
def update_submobject_list(self, index):
141141
self.mobject.submobjects = self.all_submobs[:index]
142142

143+
class AddTextLetterByLetter(ShowIncreasingSubsets):
144+
"""
145+
Add a Text Object letter by letter on the scene. Use time_per_char to change frequency of appearance of the letters.
146+
"""
147+
CONFIG = {
148+
"suspend_mobject_updating": False,
149+
"int_func": np.ceil,
150+
"rate_func" : linear,
151+
"time_per_char": 0.1,
152+
}
153+
154+
def __init__(self, text, **kwargs):
155+
digest_config(self, kwargs)
156+
157+
self.run_time = np.max((0.06, self.time_per_char)) * len(text) #Time_per_char must be above 0.06. Otherwise the animation doesn't finish.
158+
super().__init__(text, **kwargs)
143159

144160
class ShowSubmobjectsOneByOne(ShowIncreasingSubsets):
145161
CONFIG = {

0 commit comments

Comments
 (0)