Activity › Forums › Adobe After Effects Expressions › Modify Expand Contract expression
-
Modify Expand Contract expression
Posted by Zach Meissner on December 18, 2008 at 11:11 pmmaxDev = 10; // max deviation in pixels spd = 20; //speed of oscillation decay = 1.0; //how fast it slows down if (marker.numKeys > 0){ t = time - marker.key(1).time; if (t >=0 ){ x = scale[0] + maxDev*Math.sin(spd*t)/Math.exp(decay*t); y = scale[0]*scale[1]/x; [x,y] }else{ value } }else{ value }Trying to modify the wonderful expand and contract expression that Dan made to only do it on the Y axis instead of both. I’m sure it’s simple, but i just cant figure it out. Thanks!
Zach Meissner replied 16 years, 4 months ago 2 Members · 8 Replies -
8 Replies
-
Dan Ebberts
December 19, 2008 at 1:05 amThis should do it:
maxDev = 10; // max deviation in pixels
spd = 20; //speed of oscillation
decay = 1.0; //how fast it slows downif (marker.numKeys > 0){
t = time – marker.key(1).time;
if (t >=0 ){
y = scale[0] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
[value[0],y]
}else{
value
}
}else{
value
}Dan
-
Zach Meissner
December 19, 2008 at 6:43 amThanks Dan! Is there an easy way to disable the expression with a another layer marker, or with a checkbox control? I want to change just the Y value of text to make appear to sink into the ground at a certain time, but i cant keyframe the scale because the expression is in use. I figure it’s easy to do with a layer marker but i wasn’t sure how. Thanks a bunch!!
-
Dan Ebberts
December 19, 2008 at 3:28 pmAh, I think that’s because there’s an error in the expression. Try changing the long line to this:
y = scale[1] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
That should keep everything live for keyframing.
Dan
-
Zach Meissner
December 22, 2008 at 8:33 pmHey Dan, if i wanted to turn the expression on again at another layer marker, how would i modify it? I’m thinking something with the ‘key(1)’ text, but i’m not sure. Thanks!
-
Dan Ebberts
December 22, 2008 at 8:44 pmThis should trigger at each layer marker:
maxDev = 10; // max deviation in pixels
spd = 20; //speed of oscillation
decay = 1.0; //how fast it slows downn = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){
n–;
}
}if (n > 0){
t = time – marker.key(n).time;
y = scale[1] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
[value[0],y]
}else{
value
}Dan
-
Zach Meissner
April 14, 2010 at 7:05 pmHi Dan, back again. Trying to get this to only be on the X axis. I’ve replaced the X and Y text, but that didn’t work.
How can I get the expression to only do the x and not the y?
maxDev = 10; // max deviation in pixels
spd = 20; //speed of oscillation
decay = 1.0; //how fast it slows downn = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){
n--;
}
}if (n > 0){
t = time - marker.key(n).time;
y = scale[1] + maxDev*Math.sin(spd*t)/Math.exp(decay*t);
[value[0],y]
}else{
value
}
Reply to this Discussion! Login or Sign Up