Adding Color to "$" symbol in counting script

Moderators: Disciple, zlovatt

Post Reply
Speedcola
Posts: 1
Joined: December 2nd, 2019, 2:55 pm

December 2nd, 2019, 3:42 pm

I'm using the expression below to add a dollar counter to my comp and it works great. Problem is I can only add one color and I would like to change the color of the dollar symbol. The ability to plug in a color code in the variables for it would work great. I had a friend who's develops try to write it in for me but it didn't work. Here is what he wrote. I think he was on the right track but an expression error would show up for the "dollarSign" portion.

Code: Select all

var myColor = rgbToHsl([159,27,41,255]/255);
and

Code: Select all

if(dollarSign) prefix = dollarSign.myColor + "$";

Code: Select all

numDecimals = 0;
commas = true;
dollarSign = true;
beginCount = 0;
endCount = 1000000;
dur = 2;
 
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;
}
Post Reply