Expression Copied to Clipboard! πŸ—‚
← Back to Expressions

Get Center & Scale of Comp - After Effects Expression

How to use the Composition Width & Height expression to center and scale a layer

Get Center & Scale of Comp

Copied to Clipboard!
[thisComp.width,thisComp.height] * 0.5;

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

  1. Set your selected layer's anchor point to the center of the layer.
  2. Apply this expression to the position property
  3. Done!
[thisComp.width,thisComp.height] * 0.5;

How to Scale a Shape Layer to the Size of your Comp

  1. Create a rectangle shape layer
  2. 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