
プレビューの猫のしっぽはアニメーション化されたパスで、これをループさせる方法を紹介します。
After Effectsでパスをループさせる方法は?
PathプロパティをAlt+クリックし、下記のエクスプレッションを貼り付けます。
// if you don't need pingpong - false
pingPong = false;
try{
// start - first keyframe
timeStart = thisProperty.key(1).time;
// count duration
duration = thisProperty.key(thisProperty.numKeys).time - timeStart;
// cycle number
quant = Math.floor((time – timeStart) / duration);
if (quant < 0) quant = 0 // != 0
if (quant % 2 == 1 && pingPong == true){
t = 2 * timeStart + (quant+1) * duration – time;
} else {
t = time-quant*duration;
}
} catch(e) {
t = time;
}
thisProperty.valueAtTime(t);
このエクスプレッションは、下記の標準的なループサイクルのエクスプレッションと同じように動作します。
loopOut(type="cycle");
パスを「ピンポン」のようにループさせる方法は?
PathプロパティをAlt+クリックし、下記のエクスプレッションを貼り付けます。
// if you don't need pingpong - false
pingPong = true;
try{
// start – first keyframe
timeStart = thisProperty.key(1).time;
// count duration
duration = thisProperty.key(thisProperty.numKeys).time – timeStart;
// cycle number
quant = Math.floor((time – timeStart) / duration);
if (quant < 0) quant = 0 // !=0
if (quant % 2 == 1 && pingPong == true) {
t = 2 * timeStart + (quant + 1) * duration – time;
} else {
t = time – quant * duration;
}
} catch(e) {
t = time;
}
thisProperty.valueAtTime(t);
このエクスプレッションは、下記の標準的なループ「pingpong」のエクスプレッションと同じように動作します。
loopOut(type="pingpong");
