ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to find the sum of the vectors inside a custom array?

COW Forums : Adobe After Effects

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Respond to this post   •   Return to posts index   •   Read entire thread


Crystal Goh
How to find the sum of the vectors inside a custom array?
on Oct 25, 2019 at 6:55:45 am

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...

Would 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(???);



Posts IndexRead Thread 


Current Message Thread:





© 2020 CreativeCOW.net All Rights Reserved
[TOP]