Displaying text letter by letter

Welcome to the Processing Community, @Polo!

Your textAnimated function contains this conditional block:

    if t<len(toType):
        textAnimated(toType,x,y,True)

Therefore, the function calls itself. Are you intentionally writing the function as a recursion?

EDITED 2x on July 7, 2021 to add the following:

To follow @tabreturn’s advice, you can add this prior to your function definition:

toTypeR = ""
t = 0
def setup():
    size(400, 100)
    noLoop()
def draw():
    textAnimated("This is the text!", 0, 20, True)

You may see the entire text appear all at once, which does not seem to be what you wanted.

Fitting the recursion into the code structure of a Processing sketch to implement an animation can be tricky. You may benefit from reading the following discussion thread for guidance:

Is my fractal optimized? Could it animate?

Though it focuses on Java Mode, it does include a Python Mode example.

Also see Tower Hanoi - Why recursive draw only first and last steps?.

3 Likes