Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoodBoyNinja/84ecbc838256b905c7ed7f9aeb809685 to your computer and use it in GitHub Desktop.
Save GoodBoyNinja/84ecbc838256b905c7ed7f9aeb809685 to your computer and use it in GitHub Desktop.
When applied to a text layer source text, it will show "+ / - " according to whether the point the expression is looking at is speeding up or slowing down.
function AccelDeccel(point) {
xResult = "";
yResult = "";
pointVelocity = point.velocity;
pointVelocityLastFrame = point.velocityAtTime(time - thisComp.frameDuration);
xVelocityNow = Math.abs(pointVelocity[0]);
yVelocityNow = Math.abs(pointVelocity[1]);
xVelocityLastFrame = Math.abs(pointVelocityLastFrame[0]);
yVelocityLastFrame = Math.abs(pointVelocityLastFrame[1]);
xResult = (xVelocityNow > xVelocityLastFrame && xVelocityNow) ? "+" : (xVelocityNow < xVelocityLastFrame && xVelocityNow) ? "-" : "";
yResult = (yVelocityNow > yVelocityLastFrame && yVelocityNow) ? "+" : (yVelocityNow < yVelocityLastFrame && yVelocityNow) ? "-" : "";
return [ xResult, yResult ];
}
AccelDeccel(/*pickqhip a point here, like a layer's poition property*/);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment