Last active
September 23, 2019 11:39
-
-
Save Volorf/a51188ee86ed09eaa14e506a62d29215 to your computer and use it in GitHub Desktop.
Counter for After Effects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initial and last frames of an animation. | |
var startKeyFrame = 30; | |
var endKeyFrame = 50; | |
// Initial and final values of a text layer. | |
var startValue = 500; | |
var endValue = 1000; | |
// Util vars for a calc function | |
var currentFrame = time/thisComp.frameDuration, | |
deltaKeyFrames = endKeyFrame - startKeyFrame, | |
deltaValues = endValue - startValue, | |
unit = deltaValues / deltaKeyFrames, | |
deltaFrames = currentFrame - startKeyFrame; | |
// Create the calc function. | |
function counterFunc () { | |
if (currentFrame <= startKeyFrame) { | |
return text.sourceText = startValue; | |
} else if (currentFrame > startKeyFrame && currentFrame < endKeyFrame) { | |
return text.sourceText = Math.round(startValue + unit * deltaFrames); | |
} else if (currentFrame >= endKeyFrame) { | |
return text.sourceText = endValue; | |
}; | |
}; | |
// Call the calc function. | |
counterFunc(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment