Skip to content

Instantly share code, notes, and snippets.

  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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