Skip to main content
chrisc59063722
Participant
September 9, 2022
質問

Scale Down Bounce Expression

  • September 9, 2022
  • 返信数 1.
  • 1011 ビュー

I have a bounce expression that works when scaling up, but it doesn't work when I scale down. I need an expression that adds a bounce when scaling down. 

このトピックへの返信は締め切られました。

返信数 1

Dan Ebberts
Community Expert
Community Expert
September 9, 2022

What's the scale up expression? It should help to define the kind of motion you're looking for on scale down.

chrisc59063722
Participant
September 9, 2022

This is the expression I use. 

amp = .03;

freq = 3.0;

decay = 5.0;

n = 0;

time_max = 4;

if (numKeys > 0){

n = nearestKey(time).index;

if (key(n).time > time){

n--;

}}

if (n == 0){ t = 0;

}else{

t = time - key(n).time;

}

if (n > 0 && t < time_max){

v = velocityAtTime(key(n).time - thisComp.frameDuration/10);

value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

}else{value}

 

Numbers with Commas

var num = effect("Slider Control")("Slider")

num = Comma(num);

[num]

 

function Comma(number)

{

number = '' + Math.round(number);

if (number.length > 3)

{

var mod = number.length % 3;

var output = (mod > 0 ? (number.substring(0,mod)) : '');

for (i=0 ; i < Math.floor(number.length / 3); i++)

{

if ((mod == 0) && (i == 0))

output += number.substring(mod+ 3 * i, mod + 3 * i + 3);

else

output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);

}

return (output);

}

else return number;

}

 

Dan Ebberts
Community Expert
Community Expert
September 9, 2022

It works for me, going in either direction (it even goes below zero if your last keyframe is close enough to zero). What's the particular issue you're seeing?