Skip to main content
Participant
Jan 26, 2024 12:33 PM UTC
Question

An expression that adds up

Hello,

I'm trying to find out if there's an expression that adds up every X images?

The problem:
A machine that 2 times per second will increase its value by 88kg.
In other words, a calculation that would add the imposed figure of 23604 by 88 every 12 images.

As I couldn't find this calculation, I did it by hand ^^, but I'd still like to find a less restrictive solution.

Thanks

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Community Expert
Jan 26, 2024 1:42 PM UTC

If you start by subtracting the layer's inPoint from the time, then divide that number by the interval and use Math.floor() to keep the value a whole number, you will get an even number multiplier you can use to add that value to a starting number. The expression is fairly simple. Add it to a text layer/Text property and you have your counter.

t = time - inPoint;
count = t / .5; // interval time in seconda
num = Math.floor(count);
step = 88 * num; // value increase
strt = 23604 + step; // starting Number
result = strt + "kg"

To keep the numbers from bouncing around, you will need to use a monospaced font like Courier;

 

 

 

Translate
Participant
Jan 26, 2024 4:30 PM UTC

Thank you very much! It works perfectly 🙂

Translate