If I had 3 lines of manim text,
l = TextMobject("Line 1")
l2 = TextMobject("Line 2")
l3 = TextMobject("Line 3")
and I wanted to animate them all together, how would I do that? I'm looking for something easier to type and more pythonic than
v = np.array([-3, 2, 0]) # Vector to translate the text by
self.play(ApplyMethod(l.shift, v), ApplyMethod(l2.shift, v), ApplyMethod(l3.shift, v))
Something more like:
lines = [l, l2, l3]
g = GroupMobjects(*lines)
v = np.array([-3, 2, 0]) # Vector
self.play(ApplyMethod(g.shift, v))
Where I just made up the GroupMobjects
syntax for the above example.
I've looked at using VGroup
, and it seems like a good match for what I'm trying to accomplish, but the problem is that I have no clue how to use it, and manim doesn't have the best documentation (although for a good reason).
Any solutions would be appreciated.
There are two types of containers in Manim, Groups
and VGroups
, the difference is that VGroups
can only contain VMobjects
(objects based on Bezier curves), whereas Groups
can be of other types like Images (you cannot group images in VGroups
, only in Groups
).
As I have already explained here, the complete documentation does not exist, only parts (EulerTour and TB). If you want to learn how they are used, I can leave this and this links, but in general, for now, you will have to learn from the source code (VGroup
is a subclass of VMobject
, and VMobject
is a subclass of Mobject
).