-
How to find the sum of the vectors inside a custom array?
Hi all, I am pretty new to expressions and trying to do an expression that finds the total width from my image layers ( which all have different widths, number of image layers not fixed).
My current issue is not knowing how to sum up the vectors inside the array I made. This stackflow thread has answered the question but when using their code, I still get errors: https://stackoverflow.com/questions/1230233/how-to-find-the-sum-of-an-array-of-numbersWould really appreciate any help!
// Variables
var myArray = [];
var i = 0;
var curLayer = thisComp.layer(i);// Execution
for (; i<=thisComp.numLayers ; i++){
myArray.push(curLayer.sourceRectAtTime().width);
}myArray.slice(2); /*Theres 2 layers in my comp that are not image layers, hence slicing them off.*/
//Next line am VERY unclear on getting the total width number with reduce()
return myArray.reduce(???);