Created
August 20, 2015 16:19
-
-
Save mortenjust/3dfc8efa0aa4422a9a2b to your computer and use it in GitHub Desktop.
After effects counter expression
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
// Add the following expression for Source Text (Copy the expression, Alt-Click the Source Text Stopwatch, Paste, click outside the box): | |
// http://www.motionscript.com/design-guide/counter.html | |
numDecimals = 0; | |
commas = true; | |
dollarSign = false; | |
beginCount = 0; | |
endCount = 130000; | |
dur = 4; | |
t = time - inPoint; | |
s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals); | |
prefix = ""; | |
if (s[0] == "-"){ | |
prefix = "-"; | |
s = s.substr(1); | |
} | |
if(dollarSign) prefix += "$"; | |
if (commas){ | |
decimals = ""; | |
if (numDecimals > 0){ | |
decimals = s.substr(-(numDecimals + 1)); | |
s = s.substr(0,s.length - (numDecimals + 1)); | |
} | |
outStr = s.substr(-s.length, (s.length-1)%3 +1); | |
for (i = Math.floor((s.length-1)/3); i > 0; i--){ | |
outStr += "," + s.substr(-i*3,3); | |
} | |
prefix + outStr + decimals; | |
}else{ | |
prefix + s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment