ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

sourceRectAtTime + scale?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kieran Lefort
sourceRectAtTime + scale?
on May 7, 2019 at 2:46:53 pm

I have two layers: a single line text layer (“Name”) and a logo layer. The logo needs to stay the same distance from the right edge of the text, no matter how long the text is. I separated the x & y values of the Position of the logo and used the attached expression on the X Position and it works really well.

(If you sensed a “however” coming, you’d be right and here it is…)

HOWEVER the text layer needs to scale (controlled by a slider) to make sure longer names stay on the screen and the expression can’t account for the scale; it only reacts to the length of the text layer.

What should I be adding to the expression so the logo stays the same distance from the from the right edge of the text, based on both the length of the and the scale?

Simply adding the scale property doesn't work, as AE sees it as an objective number and just adds the number.

Thanks in advance.

myLayer = thisComp.layer("Name");
rectHeight = myLayer.sourceRectAtTime().height;
rectWidth = myLayer.sourceRectAtTime().width;
rectLeft = myLayer.sourceRectAtTime().left;
rectTop = myLayer.sourceRectAtTime().top;
xPos = myLayer.toComp(myLayer.anchorPoint)[0];
x = rectLeft + xPos + rectWidth +50;


Return to posts index

Filip Vandueren
Re: sourceRectAtTime + scale?
on May 7, 2019 at 3:44:27 pm

Would setting your text as right aligned and making sure its anchorpoint is at 0,0, not work? No expressions needed



Return to posts index

Griffin Englander
Re: sourceRectAtTime + scale?
on May 7, 2019 at 11:46:47 pm

Hey Kieran,

You basically have to take the width and multiply it by your scale.

Try this..

myLayer = thisComp.layer("Name");
rectHeight = myLayer.sourceRectAtTime().height;
widthTemp = myLayer.sourceRectAtTime().width;
rectWidth = (widthTemp*myLayer.transform.scale[0])/100;
rectLeft = myLayer.sourceRectAtTime().left;
rectTop = myLayer.sourceRectAtTime().top;
xPos = myLayer.toComp(myLayer.anchorPoint)[0];
x = rectLeft + xPos + rectWidth +50;


Return to posts index


Kieran Lefort
Re: sourceRectAtTime + scale?
on May 8, 2019 at 11:03:17 am

And Griffin is the winner! That has solved my problem completely. Thank you so much.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]