β Back to Expressions
How to use the Composition Width & Height expression to center and scale a layer
Get Center & Scale of Comp
How to get the center of a Composition in After Effects
Ever needed to get the center position of your composition? Thankfully, it's pretty easy with a simple expression.
At any time, you can use thisComp.width and thisComp.height to get the width and height of your current comp.
[thisComp.width, thisComp.height] // 1920,1080
And then you can use that value to position or scale other layers!
How to Place a layer at the center of your comp
- Set your selected layer's anchor point to the center of the layer.
- Apply this expression to the position property
- Done!
[thisComp.width,thisComp.height] * 0.5;
How to Scale a Shape Layer to the Size of your Comp
- Create a rectangle shape layer
- Click on the "Size" property of the Rectangle and apply this expression
[thisComp.width, thisComp.height]
Now, Β use the previous expression to set the position of the layer to the center, and use this one to make the Rectangle fill the size of the comp.
Boom, you have a dynamic Background Layer that will always fill the background of the comp, no matter the size!
If you want to be even more fancy, you can save this layer as a Preset and re-use it with one click at any time.
More expressions you might like...
Credit
Get Β After Effects tips & tricks
delivered to your inbox
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.