FORUMS: list search recent posts

Scale-animation triggerd by sourceRectAtTime

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mårten Gunge
Scale-animation triggerd by sourceRectAtTime
on May 17, 2017 at 11:03:52 am

Hi.

I've got myself a solid and a text layer. Depending on how many lines the sourcetext is the solid scale changes.

So far so good.

Now what I want is a neat way to make the solid animate between the scale values. Maybe over half a second. Preferably with easing.

rect = thisComp.layer("Textlayer").sourceRectAtTime(time,false);
X = 100;
Y = rect.height;
if (Y>125) [Y=95];
else if (Y>55) [Y=75];
else [Y=50];
[X,Y]


Return to posts index

Dan Ebberts
Re: Scale-animation triggerd by sourceRectAtTime
on May 17, 2017 at 4:10:52 pm

The key is finding a decent trigger. What causes the text to change?

Dan



Return to posts index

Mårten Gunge
Re: Scale-animation triggerd by sourceRectAtTime
on May 17, 2017 at 5:46:27 pm

Thanks for quick response.

Well. Its kind of a chain reaction kind of a thing.

I am using comps from spreadsheets to input text in four different textlayers. The textlength vary between one and three lines. To make the expression work I made a new textlayer ("Textlayer") which uses the sourcetext from the four original layers at certain times (see expression below).

So I guess we could make some sort of time markers since its always happening at the same time...

The main objective is to make the textbox scale up or down accordingly to the number of rows in the texts with an animation.

if(time&lt;8)(thisComp.layer("^Text1").text.sourceText)

else if(time&lt;15)(thisComp.layer("^Text2").text.sourceText)

else if(time&lt;23)(thisComp.layer("^Text3").text.sourceText)

else(thisComp.layer("^Text4").text.sourceText);


Return to posts index


Dan Ebberts
Re: Scale-animation triggerd by sourceRectAtTime
on May 17, 2017 at 6:16:38 pm

I haven't tested any of this, so it's pretty rough, and there are probably better ways to do it, but something like this might work:


t1 = 8;
t2 = 15;
t3 = 23;
ramp = .25;
rect = thisComp.layer("Textlayer").sourceRectAtTime(time,false);
x = 100;
h = rect.height;
if (h>125) y=95;
else if (h>55) y=75;
else y=50;
s = [x,y]
if (time < t1){
s;
}else if (time125) y=95;
else if (h>55) y=75;
else y=50;
prevS = [x,y];
linear(time,t1,t1+ramp,prevS,s);
}else if (time125) y=95;
else if (h>55) y=75;
else y=50;
prevS = [x,y];
linear(time,t2,t2+ramp,prevS,s);
}else{
rect = thisComp.layer("Textlayer").sourceRectAtTime(t3-thisComp.frameDuration,false);
h = rect.height;
if (h>125) y=95;
else if (h>55) y=75;
else y=50;
prevS = [x,y];
linear(time,t3,t3+ramp,prevS,s);
}



Dan



Return to posts index

Mårten Gunge
Re: Scale-animation triggerd by sourceRectAtTime
on May 18, 2017 at 7:18:47 am

Hello again.

Seems to be a problem with the "else if" on line 19. Maybe a curly bracket to mush? Maybe a double else? Maybe something completely else else...

Any idea?





Return to posts index

Dan Ebberts
Re: Scale-animation triggerd by sourceRectAtTime
on May 18, 2017 at 4:03:13 pm

Sorry, that really got mangled. This should be better:


t1 = 8;
t2 = 15;
t3 = 23;
ramp = .25;
function getXY(theTime){
x = 100;
rect = thisComp.layer("Textlayer").sourceRectAtTime(theTime,false);
h = rect.height;
if (h>125) return [x,95];
if (h>55) return [x,75];
return [x,50];
}
s = getXY(time);
if (time < t1){
s;
}else if (time < t2){
prevS = getXY(t1/2);
linear(time,t1,t1+ramp,prevS,s);
}else if (time < t3){
prevS = getXY((t1+t2)/2);
linear(time,t2,t2+ramp,prevS,s);
}else{
prevS = getXY((t2+t3)/2);
linear(time,t3,t3+ramp,prevS,s);
}



Dan



Return to posts index


Mårten Gunge
Re: Scale-animation triggerd by sourceRectAtTime
on May 23, 2017 at 11:48:53 am

That actually worked exactly the way I wanted it too.
I am knee deep in gratitude.
Or, as we say in Sweden. Tack så mycket!


Return to posts index

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