Activity › Forums › Adobe After Effects Expressions › Scale-animation triggerd by sourceRectAtTime
-
Scale-animation triggerd by sourceRectAtTime
Posted by Mårten Gunge on May 17, 2017 at 11:03 amHi.
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]Mårten Gunge replied 9 years, 3 months ago 2 Members · 6 Replies -
6 Replies
-
Dan Ebberts
May 17, 2017 at 4:10 pmThe key is finding a decent trigger. What causes the text to change?
Dan
-
Mårten Gunge
May 17, 2017 at 5:46 pmThanks 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<8)(thisComp.layer("^Text1").text.sourceText)else if(time<15)(thisComp.layer("^Text2").text.sourceText)
else if(time<23)(thisComp.layer("^Text3").text.sourceText)
else(thisComp.layer("^Text4").text.sourceText);
-
Dan Ebberts
May 17, 2017 at 6:16 pmI 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
-
Mårten Gunge
May 18, 2017 at 7:18 am -
Dan Ebberts
May 18, 2017 at 4:03 pmSorry, 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
-
Mårten Gunge
May 23, 2017 at 11:48 am
Reply to this Discussion! Login or Sign Up


