Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Ping Pong Loop of Color Fill

  • Ping Pong Loop of Color Fill

    Posted by Paul Kamuf on January 15, 2016 at 8:04 pm

    Hi,

    I would like to loop the fill color of a layer, so it fades from blue to gray, gray back to blue and repeats forever.

    I have two ideas but they don’t seem to be working. Is there a simple way to ping pong loop “linear”? (I tried a little If statement that played a reverse version of the linear, but it introduced a color flash)

    Maybe there is a better way with a Sin curve driving the transition?

    Bonus if there is variable to hold at the point it is full gray and full blue.

    Thank you in advance!
    Paul

    blue = thisComp.layer("COLORS").effect("Color1")("Color")
    gray = thisComp.layer("COLORS").effect("Gray")("Color")
    loopTime = 1;
    t = time % loopTime;
    linear(t, 0, loopTime, blue, gray)

    Dan Ebberts replied 10 years, 6 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    January 15, 2016 at 8:35 pm

    Try this:

    blue = thisComp.layer(“COLORS”).effect(“Color1”)(“Color”);
    gray = thisComp.layer(“COLORS”).effect(“Gray”)(“Color”);
    loopTime = 1.;
    holdTime = .5;
    t = time % loopTime;
    loops = Math.floor(time/loopTime);
    if (loops%2)
    linear(t, 0, loopTime-holdTime, gray, blue)
    else
    linear(t, 0, loopTime-holdTime, blue, gray);

    Dan

  • Paul Kamuf

    January 15, 2016 at 10:00 pm

    Hi,

    Thank you Dan.

    If you have time, would you mind breaking it down, in particular how the if with the modulus works…

    if (loops%2)

    Thanks,
    Paul

  • Dan Ebberts

    January 15, 2016 at 10:22 pm

    loops%2 evaluates to true if there have been an odd number of loops (not counting the current one).

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy