ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Centering a dynamic square-expression-based text-layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Joe Richardson
Centering a dynamic square-expression-based text-layer
on Nov 2, 2019 at 5:54:09 am
Last Edited By Joe Richardson on Nov 2, 2019 at 6:47:45 am

Sorry for the confusing title.

I made a text layer that squares itself over time. So 1 copy becomes 2, 4, 6, 8 using a couple of For-Loops:

The problem Im having is that I want to keep the anchorpoint and the whole text centered every time it expands. For instance, at one second, "hello" is alone onscreen in the center of the composition. Then later on, it's 4 "hello"'s, -- and i'd like to keep it centered as it continues to square itself over time.

I sorta-get results using sourceRectAtTime, but I'm not sure how to keep it centered every time it expands. I figure it's a calculation in both the anchorPoint and position values that involves the amount the slider is on, but i'm not sure.

Thanks
the 'square'.
s = effect("Square Slider")("Slider");
var x = s // slider control that's keyframed;
var y = s;
var str1 = "";
var str2 = "";
for (i = 0; i &lt; x; i++)
{
str1 += " hello "
}
for (i = 0; i &lt; y; i++)
{
str2 += (str1 + "\r")
}
str2


a janky solution was using sourceRectAtTime and setting the anchorpoint to height/2, width/2, and nudging the position of the layer til it's 'centered'


Return to posts index

Andrei Popa
Re: Centering a dynamic square-expression-based text-layer
on Nov 2, 2019 at 7:26:30 am

This should be the expression of your anchorPoint
var myWidth = sourceRectAtTime(time,false).width;
var left = sourceRectAtTime(time,false).left;
var myHeight = sourceRectAtTime(time,false).height;
var top = sourceRectAtTime(time,false).top;
[left+myWidth/2,myHeight/2+top]


Andrei
My Envato portfolio.


Return to posts index

Joe Richardson
Re: Centering a dynamic square-expression-based text-layer
on Nov 2, 2019 at 7:57:42 am

Thank you. I feel like an idiot. I had set up all the 4 sRaT variables like you, but I had no idea how to combine them >_>


Return to posts index

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