| **Expression to scale layers at different rates or starting times, with loop cycle**
on Jul 23, 2018 at 4:09:20 pm |

The project is a short looping video for social media, in which one element desired is a suggestion of twinkling stars in a night sky seen through a window. (all simple Illustrator images) The initial thought was just to have the individual star layers (in a nested comp) to slightly scale up and down slowly and to cycle. One expression that works is shown below.

(The odd 'freq' value was to get the cycle to complete within the current duration of the overall animation.)

But when applied to all layers, they all 'pulsate' at the same rate because they all have the same starting point. If the rates are changed, then I imagine it wouldn't be possible to get seamless looping. (Some would 'jump' from one scale percentage to another at end.)

Suggestion for getting some offset in the scaling so the pulsations look more random, but also being able to loop them? Or maybe another, entirely different way to simulate star twinkling/pulsing? (I tried some particle systems but couldn't find one that quite did this.)

`freq = 0.1589; //frequency (cycles per second)`

ampl = 30; //amplitude (pixels)

x = ampl*Math.sin(time*freq*Math.PI*2);

y = ampl*Math.sin(time*freq*Math.PI*2);

value + [x,y]

| **Re: Expression to scale layers at different rates or starting times, with loop cycle** on Jul 23, 2018 at 4:49:29 pm |

Try it this way:

freq = 0.1589; //frequency (cycles per second)

ampl = 30; //amplitude (pixels)

seedRandom(index,true);

offset = random(Math.PI*2);

x = ampl*Math.sin(time*freq*Math.PI*2+offset);

y = ampl*Math.sin(time*freq*Math.PI*2+offset);

value + [x,y]

Dan