Someone previously asked how to create this effect. I replied at the time, but without giving the complete solution. I can no longer find that post, so here is my commented setup.
It uses only one expression (or two, just for convenience).
Text and mask
First, create a Text+ node and add two keyframes to change the text.
Then, merge the text over a transparent Background using a Rectangle mask with a size of 1 x 1, centered at 1, 0.5.
By animating the text’s H Anchor from -1 to +1, you can make the text appear and disappear.
Adding the Ellipse
Next, merge an Ellipse masking a colored Background on top of the text
Then add an AutoDomain node. This determines the size of the whole result, its Domain of Definition (DoD).
Centering Text and Ellipse
We can now use that information to recenter everything with a Transform node. Set its Center to the following expression:
Point(
((AutoDomain1.Output.DataWindow.right - AutoDomain1.Output.DataWindow.left) / AutoDomain1.Output.Width - Ellipse2.Width) / 2 + .5,
.5
)
The formula may look painful, but it works. The DataWindow is simply the Domain of Definition output by the AutoDomain node.
If you stop here, you will notice that the ellipse stays over the text. The trick is to add a few spaces at the end of both text strings.
Using the Comments field
This is where the second expression comes in, purely for convenience.
Instead of manually adding spaces to each text, you can move the text into the Comments field. The Comments field does not accept keyframes, but it can be made keyframable.
- Right-click the Comments field.
- Choose Edit Control…
- Immediately click OK.
- You can now enter the two words (or more) and keyframe them.
Then, go back to the Text field of the Text+ node and add this expression:
Comments.Value .. " "
This concatenates the keyframed Comments value with a space.
Finally, add as many spaces as needed, depending on the font size, to push the ellipse away from the text. There is probably a more rigorous way to calculate this, but it would require a more complicated expression, and the result would not look as good.
The composition is here: https://pastebin.com/gePn9wFk