ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Sum variable from all previous frames

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Josh Wrobel
Sum variable from all previous frames
on Nov 9, 2019 at 7:16:38 pm

I am working on a project right now where I need to find the integral of a variable over time. I am trying to set up an expression to do the summation of the variable from frame = 0 to the current frame/time. Is there an easy way to do this? If not, how can I create this expression? Thanks for the help!


Return to posts index

Dan Ebberts
Re: Sum variable from all previous frames
on Nov 9, 2019 at 8:40:22 pm

It's brute force, I'm afraid. It may depend on how your variable is defined, but in general, this would be one way:


myVar = effect("Slider Control")("Slider"); //define your variable here
f = timeToFrames(time);
accum = 0;
for (i = 0; i <= f; i++){
accum += myVar.valueAtTime(framesToTime(i));
}
accum



Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]