ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Auto-resize text box -> Box doesn't stay in place

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
aniello ferrone
Auto-resize text box -> Box doesn't stay in place
on Oct 9, 2019 at 10:36:14 am
Last Edited By aniello ferrone on Oct 9, 2019 at 11:14:47 am

Hi masters, how are you? I saw a lot of guide to self-resize box, but nobody seems to care about this problem.

I made an auto-resize text box, and i really like this expression I used in the position of the shape layer, that allows me to scale the box proportionally and justify the text (paragraph) both right and left. Here it is

var s = thisComp.layer("Text") ;
var h = s.sourceRectAtTime().height/2 ;
var w = s.sourceRectAtTime().width/2 ;
var t = s.sourceRectAtTime().top ;
var l= s.sourceRectAtTime().left ;

[w+l,h+t] ;

The only problem with this expression, is that the position of the box slightly change everytime, according to different lenght of text (like you see in this video)
https://www.dropbox.com/s/4qrihc4onncaj6u/expample.mov?dl=0

When I used just this one in the position, it didn't happen

content("Rectangle 1").content("Rectangle Path 1").size/2

So I want the box to stay in place, how can i do?

Thanks to the help your giving me those days
Aniello

Aniello Ferrone
Viral Video Editor
http://www.fanpage.it


Return to posts index

aniello ferrone
Re: Auto-resize text box -> Box doesn't stay in place
on Oct 9, 2019 at 11:21:43 am

I think this is the problem, but i can't understand how to set it

var l= s.sourceRectAtTime().left ;

Aniello Ferrone
Viral Video Editor
http://www.fanpage.it


Return to posts index

Tomas Bumbulevičius
Re: Auto-resize text box -> Box doesn't stay in place
on Oct 13, 2019 at 2:10:32 pm

Hey Aniello, try applying the following expression to shape's anchor point. It will stick in the middle for this case.

In order to changes its anchor point placement, adjust value in the brackets, to reflect it.


Currently, it reads 'take left value of the layer, add half of layer's width' for X, and then 'take top value of the layer and add half of its height'. This results to a center value in both, x and y. Based on this relation, you will manage to make it work to your case.

sourceSize = thisLayer.sourceRectAtTime(0, false);
T = sourceSize.top;
L = sourceSize.left;
W = sourceSize.width;
H = sourceSize.height;
([L+ W/2,T+H/2])


Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

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