Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Mr. Dan Ebberts Expression for Blinking help

  • Mr. Dan Ebberts Expression for Blinking help

    Posted by Derrick on September 16, 2006 at 9:06 pm

    Hi there, Mr. Ebberts wrote this expression about 4 years ago. I just found it in the archives of Creative Cow.

    Could someone please help me understand why this expression makes a layer blink the specified duration? I’m not understanding the math in this one.

    f=2; //duration of flash (in seconds)
    if (Math.sin(time*Math.PI/f) >= 0){
    100
    }
    else{
    0
    }

    The line I don’t get is:

    if (Math.sin(time*Math.PI/f) >= 0){

    Thanks!
    – Derrick

    Dan Ebberts replied 19 years, 9 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    September 17, 2006 at 5:10 am

    It’s just a sine wave that varies between -1 and +1. The sine wave is enclosed in a conditinal if/else so that whenever the value is between zero and one the opacity is set to 100, otherwise it is set to 0. So you really end up with the opacity being on for two seconds, off for two seconds, etc.

    Hope that helps.

    Dan

  • Derrick

    September 17, 2006 at 7:26 am

    Aaah,

    thank you Mr. Ebberts, I think I see,

    While the sine wave is above the x Axis it’s gotta positive value thus, the expression gives opacity 100% (for any positive including Zero), then when the sine wave goes to a negative value the expression gives it an opacity of 0%.

    And dividing Pi by the time you want it to take to flash on and off, you constrain the Freq of completing a full circle to take F (in this case) seconds?

    Is my understanding correct?

    Thanks,
    Derrick

  • Dan Ebberts

    September 17, 2006 at 6:07 pm

    Yeah, I think that’s pretty much it. I should have used a different variable name since f really represents half the period of the sine wave, not the frequency.

    Dan

  • Derrick

    September 17, 2006 at 7:20 pm

    Thanks Mr. Ebberts for you time.

    – Derrick

  • Dan Ebberts

    September 17, 2006 at 8:06 pm

    You’re welcome, but easy on the “Mr.” 🙂

    Dan

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