Auto Fit to Comp Size Expressions is what this tip is all about. So let’s dive right in!
Auto Fit To Comp Size with a Shape Layer
Alright so here we are in After Effects and for this example, I have an image of my kids.
and this shape layer right here.
By the way, this shape layer is an adjustment layer and has some effects applied to it.
If I turn off the Adjustment Layer, you can see what it looked like before.
I want to rig this shape layer to where it always stays the exact same size as my composition. For example, if I press CTRL+K on a PC or CMD+K on a Mac
and try to change the size of my composition just slightly like this
You can see that the shape layer is kind of affecting a lot of things here. It is not covering a lot of the new area. It didn’t change in size but my composition has. So how do I rig it up to where it is always the exact same size as my composition?
It doesn’t matter what I change in my Composition Settings, I want the shape layer to remain the same size. So let me show you how to do this.
I’m gonna CTRL-CLICK on this triangle in our timeline on PC or CMD+CLICK on a Mac.
Then I’m going to select size and press S twice on my keyboard to sole it.
ALT-CLICK on the stopwatch icon to activate the expression
and in the white text box, I’m just going to label my variable
I will type sizeX = thisComp.width;
So basically I want for sizeX to be the width of my Comp.
For the next one, I’ll do the same thing for the sizeY, but instead of width, I will say height like so: sizeY = this.Comp.height;
Okay, we are almost there!
Next, I’m going to define them in the square brackets. So I’m going to say: [sizeX, sizeY]
Alright, X is going to be sizeX and y is going to be sizeY.
So now if I let go, you will notice that nothing happens.
But let press CTRL+K on a PC or CMD+K on a Mac and open up our Composition Settings.
Auto Fit To Comp Size with a Solid
So in the last example, we use a shape layer but let me show you how to set up the exact same thing using a solid.
So now I have a solid in my composition. It is an adjustment layer and it has the exact same effects as before but how do I make this solid remain the exact same size as my composition? Let me show you!
To do that I’m going to press S on the keyboard to reveal the scale property
Then ALT+CLICK on the scale stopwatch icon.
And inside the white text field, we’re going to type some expression.
sizeX = 100*thisComp.width/thisLayer.width;
sizeX is just a variable. So basically the width of this comp divided by this.Layer.width
That is the first expression and the second we’re going to do:
sizeY = 100*thisComp.height/thisLayer.height;
Okay and now if I let go nothing happens just like it was in the last example. Let’s press CTRL+K on a PC or CMD+K on a Mac and bring up our composition settings.
Next, let’s change the size of my composition.
As you can see that it is adjusting to the size of my composition.
So here’s what I want to do, I want for this a lower third to always have the same size and have the same position as I change the size of my composition.
For example, let’s bring up our Composition Settings with the keyboard shortcut CTRL+K on a PC or CMD+K on a Mac.
So how do I fix it? Let me show you!
All you have to do is simply parent the modular lower third kit to the adjustment layer.
The adjustment layer automatically fits in size so it will basically do the exact same thing to the lower third.
So if I bring up my Composition Settings again with the keyboard shortcut CTRL+K on a PC/CMD+K on a Mac and change the size of my composition, you will see that we are scaling in size but the lower third is staying in the exact same position and size.
I hope you found this After Effects Tip useful. You can check out all of our Tips on our website. You can learn more about Expressions from my Learn After Effects Expressions Course. Definitely check it out! Also, make sure to subscribe to our email list!
Free Private Facebook Mentoring Group
Lastly, join our FREE Private Facebook Mentoring Group. It is our best FREE online resource. We have thousands of talented motion designers in this group. It is an excellent place to network and grow as a motion designer. See you in the group!