FORUMS: list search recent posts

# Interpolation - make it endless

FAQ   •   VIEW ALL
 Interpolation - make it endless on Oct 28, 2015 at 9:15:57 pm

Hello,
I'm new to javaScript,and was wondering how to achieve a pulse with Opacity changes not to use the traditional Math.sin() or Math.cos() method.
I'd like to use Interpolation methods to change Opacity from 0% to 100% and make it every two seconds and let these changes in this range last forever.
I know the classic interpolations, and I'd add the following expression to the layer's Opacity:

ease(time,inPoint,2-inPoint,[0],[100])

...It will change only the first two second. But what to modify to make it endless?

Thanks

Zs

`303450b93926828312687568`

 Re: Interpolation - make it endlesson Oct 28, 2015 at 9:29:39 pm

Do you mean you want it to repeat? Something like this should work:

d = 2; // duration
t = (time - inPoint)%d;
ease(t,0,d,0,100)

Dan

 Re: Interpolation - make it endlesson Oct 28, 2015 at 10:32:07 pm

Thank you, It works perfectly!
That's what I thought about (repeating interpolation).

Just for satisfying my curiosity, what does the second row mean basically?

t = (time - inPoint)%VARIABLE;

Zs

 Re: Interpolation - make it endlesson Oct 28, 2015 at 10:42:18 pm

It just loops t from 0 to 2, every 2 seconds (starting at the layer's in point).

Dan

 Re: Interpolation - make it endlesson Oct 28, 2015 at 10:54:37 pm

Thanks, I've learnt a lot!

Zs

 Re: Interpolation - make it endlesson Oct 29, 2015 at 10:22:43 pm

A thought crosses my mind about using this modulo (%) expression. I noticed it works like loopOut("cycle") expression with keyframes. Is there a similar modulo expression which corresponds to loopOut("pingpong")?
The reason is to get a smooth (ease) reverse to the start...

 Re: Interpolation - make it endlesson Oct 29, 2015 at 11:19:25 pm

One way:

d = 2; // duration
t = (time - inPoint)%d;
n = Math.floor((time - inPoint)/d);
n%2 ? ease(t,0,d,100,0) : ease(t,0,d,0,100)

Another:

d = 2;
50*(Math.sin((time - inPoint)*Math.PI/d - Math.PI/2) + 1)

Dan

 Re: Interpolation - make it endlesson Oct 30, 2015 at 9:34:06 pm

Many thanks again Dan!

The first is a bit difficult for me to decode, however works as I thought.

Zs

 Re: Interpolation - make it endlesson Nov 2, 2015 at 5:57:18 pm

Hello,
I rewrote your first expression for two-dimensional properties.
I applied it for Scale and converted the ternary operator to if/else conditional (because it's understandable for me) but seems I made a mistake in it. Could you point at where I did it?
Thank you...

```d = 2; // duration t = (time - inPoint)%d; n = Math.floor((time - inPoint)/d); if (value == n%2) { ease(t,0,d,[value[0]+500,value[1]+500],[value[0],value[1]]) } else { ease(t,0,d,[value[0],value[1]],[value[0]+500,value[1]+500]) }```

 Re: Interpolation - make it endlesson Nov 2, 2015 at 6:16:31 pm

Try changing this:

if (value == n%2)

to this:

if (n%2)

Dan