Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Coding syntax question

  • Coding syntax question

    Posted by Lu Nelson on February 6, 2010 at 12:31 pm

    Hi there,
    this is slightly OT, like the last post I made — but a quick question I hope for the coding experts.

    I’m trying to port a bit of code out of AE, to an environment that supports short mathematical expressions but unfortunately doesn’t support all of the normal Javascript operators.

    In the example below, there is usage of the “/=” operator and the “–” operator, and they’re not supported. My problem is they’re implemented in this bit of code (yes this particular bit is one of the well-known Penner easing equations) in a somewhat complex way such that I’m having trouble figuring out how to re-write the definition without them. Particularly, the use of “/=” inside the if condition is throwing me…

    function easeInOut (t, b, c, d) {
    if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; }

    Anyone care to take a shot at it? I'd appreciate a brief explanation too, if you don't mind -- curious to understand exactly how to deconstruct this

    Lu Nelson
    Berlin, Germany
    --
    [MacProQ2.66, 8GB, Sys10.5.6, FCP 6.0.5, AE 9.0.2]

    Lu Nelson replied 16 years, 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    February 6, 2010 at 4:13 pm

    if ((t/=d/2) < 1) is the same as t = t/(d/2); if (t < 1) Dan

  • Lu Nelson

    February 6, 2010 at 5:11 pm

    Thanks Dan,

    how about the “–” operator?

    would I translate ((--t)*(t-2) - 1) in to ((t-1)*(t-3) - 1) ?

    Lu Nelson
    Berlin, Germany

    [MacProQ2.66, 8GB, Sys10.5.6, FCP 6.0.5, AE 9.0.2]

  • Dan Ebberts

    February 6, 2010 at 5:59 pm

    I think this:

    return -c/2 * ((–t)*(t-2) – 1) + b;

    is the same as this:

    t = t-1;
    return -c/2 * (t*(t-2) – 1) + b;

    Dan

  • Lu Nelson

    February 6, 2010 at 6:57 pm

    Thanks Dan,

    it’s so great to be able to count on help when you need it!

    L.

    Lu Nelson
    Berlin, Germany

    [MacProQ2.66, 8GB, Sys10.5.6, FCP 6.0.5, AE 9.0.2]

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