ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

sourceRectAtTime

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Saso Goricar
sourceRectAtTime
on May 16, 2019 at 6:38:51 pm

Hello,

I have a problem with sourceRectAtTime expression. I would like to create a box around text, which always has an equal size on width and height. Basically, I want to create a square, which has the same width and height, when I type a different number or I a scale number.

Picture of my comp: https://www.dropbox.com/s/vi3xgtxj86jpylb/AE-Box.PNG?dl=1

As you can see, if I write down the number 1, width and height are not the same. Is it possible to always keep the same values for width or height?

Thanks for the help,
Saso

Expression on size property:
var s = thisComp.layer("1");
var w = s.sourceRectAtTime().width;
var h = s.sourceRectAtTime().height;
[w,h]


Return to posts index

Miguel de Mendoza
Re: sourceRectAtTime
on May 16, 2019 at 7:20:43 pm

Just use one of the dimensions:
var s = thisComp.layer("1");
var w = s.sourceRectAtTime().width;
var h = s.sourceRectAtTime().height;
[w,w]


Return to posts index

Saso Goricar
Re: sourceRectAtTime
on May 16, 2019 at 7:29:08 pm

Thanks for this trick, but if I write down a different number, two digits for example, I get a smaller box. Is it possible to make it dynamic, if I turn this into the .mogrt file to resize automatically?

I get this: https://www.dropbox.com/s/o9e955qloa0o3f4/AE-Box-1.PNG?dl=1

Thanks,
Saso


Return to posts index


Dan Ebberts
Re: sourceRectAtTime
on May 16, 2019 at 7:23:52 pm

Like this:

var s = thisComp.layer("1");
var r = s.sourceRectAtTime();
var m = Math.max(r.width,r.height);
[m,m]


Dan



Return to posts index

Saso Goricar
Re: sourceRectAtTime
on May 16, 2019 at 7:43:11 pm

Thanks, Dan,

that's exactly what I was trying to achieve.

I added additional slider control to adjust the margin. If you write a bigger number you could get too big box.
https://www.dropbox.com/s/xahfqzd1e687zhb/AE-Box-2.PNG?dl=1

Thanks again,
Saso


Return to posts index

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