-
Is it possible to add the values of an Array?
I’d like to have an expression to add the values of an array. I’m using sourceRectAtTime().width and xxxxx.name.match(keyword). If the amount of layers used would be constant, no problem. But they will change with each comp. (using characters in boxes to spell words). In my expression I only have the “x = Math.max(…widthlist); to see if the rest works. My goal is to keep the final word centered. Any help would be appreciated. Thanks.
keyword = "_Letter";
widthlist = [];for ( i = 1; i <= thisComp.numLayers; i++)
{
layerPath = thisComp.layer(i);const layerPathWid = layerPath.sourceRectAtTime().width;
const layerPathSWid = layerPath.transform.scale[0];
const layerPathGetWid = ( layerPathSWid - 100)* .01;
const layerPathFinWid = layerPathWid + layerPathGetWid * layerPathWid;if(layerPath.name.match(keyword)) {widthlist.push(layerPathFinWid)} else {};
};
x = Math.max(...widthlist);
[x,value[1]]