How to display some sentences one by one grouped a paragraph in manimlib?

Viewed 42

My manimgl version is 1.2.0. I have some sentences and want to display this sentences one by one, just like a normal paragraph, but whatever I adjust this paramenters, I can't get what I want. Here is my code:

from manimlib import *
class TextExample(Scene):
    def construct(s):
        t1 = Text('This can be used to group multiple VMobject instances together in order to scale.')
        t2 = Text('A group of vectorized mobjects. A group of vectorized mobjects. ')
        v = VGroup()
        v.add(t1)
        v.add(t2)
        v.arrange(direction=DOWN)
        # s.play(FadeIn(v))
        s.play(FadeIn(t1))
        s.play(FadeIn(t2))
1 Answers

You can use methods like LaggedStart or GroupAnimation on the VGroup you've already made, to display and delete VMobjects.

example of LaggedStart:

class TextExample(Scene):
def construct(s):
    delay = 0.2
    fade_time = 0.6
    v = VGroup()
    v.add(Text('This can be used to group multiple VMobject instances together in order to scale.'))
    v.add(Text('A group of vectorized mobjects. A group of vectorized mobjects. '))
    v.add(Text("Sentence number 3"))
    v.add(Text("Sentence number 4"))
    v.arrange(direction=DOWN)
    anims = [FadeIn(m, run_time = fade_time) for m in v]
    s.play(LaggedStart(*anims, lag_ratio=delay + fade_time))
Related